@@ -3782,18 +3782,32 @@ lGetConstantIntOrSymbol(Expr *expr, std::variant<std::monostate, int, Symbol*> *
37823782 return false ;
37833783 }
37843784
3785- int64_t iv[ISPC_MAX_NVEC];
3786- int count = ce->GetValues (iv);
3787- if (count < 1 ) {
3788- Error (pos, " %s must be a compile-time integer constant." , usage);
3789- return false ;
3790- }
3791- if ((int64_t )((int32_t )iv[0 ]) != iv[0 ]) {
3792- Error (pos, " %s must be representable with a 32-bit integer." , usage);
3793- return false ;
3785+ int resultValue = 0 ;
3786+ if (type->IsUnsignedType ()) {
3787+ uint64_t uv[ISPC_MAX_NVEC];
3788+ int count = ce->GetValues (uv);
3789+ if (count < 1 ) {
3790+ Error (pos, " %s must be a compile-time integer constant." , usage);
3791+ return false ;
3792+ }
3793+ if ((uint64_t )((uint32_t )uv[0 ]) != uv[0 ]) {
3794+ Error (pos, " %s must be representable with a 32-bit integer." , usage);
3795+ return false ;
3796+ }
3797+ resultValue = (int )(uint32_t )uv[0 ];
3798+ } else {
3799+ int64_t iv[ISPC_MAX_NVEC];
3800+ int count = ce->GetValues (iv);
3801+ if (count < 1 ) {
3802+ Error (pos, " %s must be a compile-time integer constant." , usage);
3803+ return false ;
3804+ }
3805+ if ((int64_t )((int32_t )iv[0 ]) != iv[0 ]) {
3806+ Error (pos, " %s must be representable with a 32-bit integer." , usage);
3807+ return false ;
3808+ }
3809+ resultValue = (int )(int32_t )iv[0 ];
37943810 }
3795-
3796- int resultValue = type->IsUnsignedType () ? (int )(uint64_t )iv[0 ] : (int )iv[0 ];
37973811 value->emplace <int >(resultValue);
37983812 return true ;
37993813}
0 commit comments