[llvm] [SystemZ] Fix bitwidth problem in FindReplicatedImm() (NFC). (PR #115383)

Ulrich Weigand via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 11 12:18:45 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);
----------------
uweigand wrote:

This still uses the size of Val rather than TotBytes, so it still pessimizes some cases (where the original Val.getExtValue() *does* fit, like in my example of a 64->32 truncating store of 0x01010101, which should use VREPI).

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


More information about the llvm-commits mailing list