[llvm] [SystemZ] Fix bitwidth problem in FindReplicatedImm() (NFC). (PR #115383)
Jonas Paulsson via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 11 12:29:09 PST 2024
================
@@ -7223,7 +7223,16 @@ SDValue SystemZTargetLowering::combineSTORE(
if (C->getAPIntValue().getBitWidth() > 64 || C->isAllOnes() ||
isInt<16>(C->getSExtValue()) || MemVT.getStoreSize() <= 2)
return;
- SystemZVectorConstantInfo VCI(APInt(TotBytes * 8, C->getZExtValue()));
+
+ APInt Val = C->getAPIntValue();
+ // Truncate Val in case of a truncating store.
+ if (!llvm::isUIntN(TotBytes * 8, Val.getZExtValue())) {
+ assert(SN->isTruncatingStore() &&
+ "Non-truncating store and immediate value does not fit?");
+ Val = Val.trunc(TotBytes * 8);
+ }
+
+ SystemZVectorConstantInfo VCI(Val);
----------------
JonPsson1 wrote:
sorry, was just about to change that.
I guess in the non-truncating case the original APInt should be of the matching bitwidth, but it doesn't hurt to be explicit and use TotBytes * 8.
And in the truncating case, it would be truncated where also the Bitwidth of the new APInt should be reduced.
https://github.com/llvm/llvm-project/pull/115383
More information about the llvm-commits
mailing list