Skip to content

Commit 45ae7d1

Browse files
authored
[SPIRV] Fix assert in getOrCreateBaseRegister for i32 -1 (#114630)
When trying to create a const inst from a 32 bit signed value, we don't want to sign-extend it to 64 bits, as the resulting value won't actually fit in an `i32` if it was negative. This fixes crashes in the following two tests after the APInt constructor asserts were enabled in #114539: ``` Failed Tests (2): LLVM :: CodeGen/SPIRV/transcoding/RelationalOperators.ll LLVM :: CodeGen/SPIRV/uitofp-with-bool.ll ```
1 parent ee29eb1 commit 45ae7d1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ Register SPIRVGlobalRegistry::getOrCreateBaseRegister(
400400
}
401401
assert(Type->getOpcode() == SPIRV::OpTypeInt);
402402
SPIRVType *SpvBaseType = getOrCreateSPIRVIntegerType(BitWidth, I, TII);
403-
return getOrCreateConstInt(Val->getUniqueInteger().getSExtValue(), I,
403+
return getOrCreateConstInt(Val->getUniqueInteger().getZExtValue(), I,
404404
SpvBaseType, TII, ZeroAsNull);
405405
}
406406

0 commit comments

Comments
 (0)