[PATCH] D36170: LSR: Fix PR33514

Evgeny Stupachenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 4 11:47:01 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL310092: Fix PR33514 (authored by evstupac).

Changed prior to commit:
  https://reviews.llvm.org/D36170?vs=109184&id=109792#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36170

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


Index: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -3672,6 +3672,12 @@
   // 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: llvm/trunk/test/Transforms/LoopStrengthReduce/pr27056.ll
===================================================================
--- llvm/trunk/test/Transforms/LoopStrengthReduce/pr27056.ll
+++ llvm/trunk/test/Transforms/LoopStrengthReduce/pr27056.ll
@@ -45,6 +45,7 @@
 ; 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()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36170.109792.patch
Type: text/x-patch
Size: 1372 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170804/c6c2da5f/attachment.bin>


More information about the llvm-commits mailing list