[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:34:29 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:

and yes, if there is a truncating store with a value that fits, this also makes a difference.

https://github.com/llvm/llvm-project/pull/115383


More information about the llvm-commits mailing list