[llvm] r310092 - Fix PR33514

Evgeny Stupachenko via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 4 11:46:13 PDT 2017


Author: evstupac
Date: Fri Aug  4 11:46:13 2017
New Revision: 310092

URL: http://llvm.org/viewvc/llvm-project?rev=310092&view=rev
Log:
Fix PR33514

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 at gmail.com>
                         <evgeny.v.stupachenko at intel.com>

Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
    llvm/trunk/test/Transforms/LoopStrengthReduce/pr27056.ll

Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=310092&r1=310091&r2=310092&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Fri Aug  4 11:46:13 2017
@@ -3672,6 +3672,12 @@ void LSRInstance::GenerateICmpZeroScales
   // 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.

Modified: llvm/trunk/test/Transforms/LoopStrengthReduce/pr27056.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/pr27056.ll?rev=310092&r1=310091&r2=310092&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopStrengthReduce/pr27056.ll (original)
+++ llvm/trunk/test/Transforms/LoopStrengthReduce/pr27056.ll Fri Aug  4 11:46:13 2017
@@ -45,6 +45,7 @@ try.cont:
 ; 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()




More information about the llvm-commits mailing list