[llvm] 45ae7d1 - [SPIRV] Fix assert in `getOrCreateBaseRegister` for `i32 -1` (#114630)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 4 05:23:47 PST 2024
Author: Justin Bogner
Date: 2024-11-04T05:23:43-08:00
New Revision: 45ae7d166ddf7265eddcfe9d0969a3408a2c7384
URL: https://github.com/llvm/llvm-project/commit/45ae7d166ddf7265eddcfe9d0969a3408a2c7384
DIFF: https://github.com/llvm/llvm-project/commit/45ae7d166ddf7265eddcfe9d0969a3408a2c7384.diff
LOG: [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
```
Added:
Modified:
llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp b/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
index 62bd8d1f9d2433..af0df4d6e5d563 100644
--- a/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
@@ -400,7 +400,7 @@ Register SPIRVGlobalRegistry::getOrCreateBaseRegister(
}
assert(Type->getOpcode() == SPIRV::OpTypeInt);
SPIRVType *SpvBaseType = getOrCreateSPIRVIntegerType(BitWidth, I, TII);
- return getOrCreateConstInt(Val->getUniqueInteger().getSExtValue(), I,
+ return getOrCreateConstInt(Val->getUniqueInteger().getZExtValue(), I,
SpvBaseType, TII, ZeroAsNull);
}
More information about the llvm-commits
mailing list