Skip to content

Commit

Permalink
[SPIRV] Fix assert in getOrCreateBaseRegister for i32 -1 (#114630)
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
bogner authored Nov 4, 2024
1 parent ee29eb1 commit 45ae7d1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 45ae7d1

Please sign in to comment.