]> granicus.if.org Git - llvm/commitdiff
Fix PR33514
authorEvgeny Stupachenko <evstupac@gmail.com>
Fri, 4 Aug 2017 18:46:13 +0000 (18:46 +0000)
committerEvgeny Stupachenko <evstupac@gmail.com>
Fri, 4 Aug 2017 18:46:13 +0000 (18:46 +0000)
Summary:
The bug was uncovered after fix of  PR23384 (part 3 of 3).
The patch restricts pointer multiplication in SCEV computaion for ICmpZero.

Reviewers: qcolombet

Differential Revision: http://reviews.llvm.org/D36170

From: Evgeny Stupachenko <evstupac@gmail.com>
                         <evgeny.v.stupachenko@intel.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310092 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopStrengthReduce.cpp
test/Transforms/LoopStrengthReduce/pr27056.ll

index 38a7cf76949d52c23d6276cfebbf2cde54dc704e..d353bbd79f860aed54e05d290a6046cb314b3cb2 100644 (file)
@@ -3672,6 +3672,12 @@ void LSRInstance::GenerateICmpZeroScales(LSRUse &LU, unsigned LUIdx,
   // Don't do this if there is more than one offset.
   if (LU.MinOffset != LU.MaxOffset) return;
 
+  // Check if transformation is valid. It is illegal to multiply pointer.
+  if (Base.ScaledReg && Base.ScaledReg->getType()->isPointerTy())
+    return;
+  for (const SCEV *BaseReg : Base.BaseRegs)
+    if (BaseReg->getType()->isPointerTy())
+      return;
   assert(!Base.BaseGV && "ICmpZero use is not legal!");
 
   // Check each interesting stride.
index 6a255f6f4e8c8d1874876175c74ec57a03668838..57dc8cd45fe73e4483f3e5f6d2ae829f8fe1f02b 100644 (file)
@@ -45,6 +45,7 @@ try.cont:                                         ; preds = %for.end
 ; CHECK-LABEL: define void @b_copy_ctor(
 ; CHECK:       catchpad
 ; CHECK-NEXT:  icmp eq %struct.L
-; CHECK-NEXT:  getelementptr {{.*}} i64 sub (i64 0, i64 ptrtoint (%struct.L* @GV2 to i64))
+; CHECK-NEXT:  %4 = sub i64 0, %1
+; CHECK-NEXT:  getelementptr {{.*}} getelementptr inbounds (%struct.L, %struct.L* @GV2, i32 0, i32 0), i64 %4
 
 declare void @a_copy_ctor()