[PATCH] D88082: [SystemZ] Make sure not to call getZExtValue on a >64 bit constant.

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 03:19:47 PDT 2020


jonpa created this revision.
jonpa added a reviewer: uweigand.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
jonpa requested review of this revision.

Add checks for the bit width in two places in SystemZTargetTransformInfo.cpp


https://reviews.llvm.org/D88082

Files:
  llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp


Index: llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
===================================================================
--- llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
+++ llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
@@ -857,7 +857,7 @@
       // A loaded value compared with 0 with multiple users becomes Load and
       // Test. The load is then not foldable, so return 0 cost for the ICmp.
       unsigned ScalarBits = ValTy->getScalarSizeInBits();
-      if (I != nullptr && ScalarBits >= 32)
+      if (I != nullptr && ScalarBits >= 32 && ScalarBits <= 64)
         if (LoadInst *Ld = dyn_cast<LoadInst>(I->getOperand(0)))
           if (const ConstantInt *C = dyn_cast<ConstantInt>(I->getOperand(1)))
             if (!Ld->hasOneUse() && Ld->getParent() == I->getParent() &&
@@ -1020,7 +1020,7 @@
     // Comparison between memory and immediate.
     if (UserI->getOpcode() == Instruction::ICmp)
       if (ConstantInt *CI = dyn_cast<ConstantInt>(UserI->getOperand(1)))
-        if (isUInt<16>(CI->getZExtValue()))
+        if (CI->getBitWidth() <= 64 && isUInt<16>(CI->getZExtValue()))
           return true;
     return (LoadOrTruncBits == 32 || LoadOrTruncBits == 64);
     break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88082.293398.patch
Type: text/x-patch
Size: 1222 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200922/69357c05/attachment.bin>


More information about the llvm-commits mailing list