[llvm-commits] [llvm] r171653 - in /llvm/trunk: lib/Transforms/Scalar/LoopStrengthReduce.cpp test/Transforms/LoopStrengthReduce/2013-01-05-IndBr.ll
Andrew Trick
atrick at apple.com
Sat Jan 5 21:59:39 PST 2013
Author: atrick
Date: Sat Jan 5 23:59:39 2013
New Revision: 171653
URL: http://llvm.org/viewvc/llvm-project?rev=171653&view=rev
Log:
Fix a crash in LSR replaceCongruentIVs.
Indirect branch in the preheader crashes replaceCongruentIVs.
Fixes rdar://12910141.
Added:
llvm/trunk/test/Transforms/LoopStrengthReduce/2013-01-05-IndBr.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=171653&r1=171652&r2=171653&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Sat Jan 5 23:59:39 2013
@@ -4820,7 +4820,7 @@
// Remove any extra phis created by processing inner loops.
Changed |= DeleteDeadPHIs(L->getHeader());
- if (EnablePhiElim) {
+ if (EnablePhiElim && L->isLoopSimplifyForm()) {
SmallVector<WeakVH, 16> DeadInsts;
SCEVExpander Rewriter(getAnalysis<ScalarEvolution>(), "lsr");
#ifndef NDEBUG
Added: llvm/trunk/test/Transforms/LoopStrengthReduce/2013-01-05-IndBr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/2013-01-05-IndBr.ll?rev=171653&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/LoopStrengthReduce/2013-01-05-IndBr.ll (added)
+++ llvm/trunk/test/Transforms/LoopStrengthReduce/2013-01-05-IndBr.ll Sat Jan 5 23:59:39 2013
@@ -0,0 +1,44 @@
+; RUN: opt -loop-reduce -S < %s | FileCheck %s
+;
+; Indirect branch in the preheader crashes replaceCongruentIVs.
+; rdar://12910141
+
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32-S128"
+
+; CHECK: @test
+; CHECK: bb8:
+; CHECK-NEXT: phi i8
+; CHECK-NEXT: phi i8
+; CHECK: ret void
+define void @test() nounwind ssp {
+bb:
+ br label %bb190
+
+bb8: ; preds = %bb190, %bb11
+ %tmp = phi i8 [ %tmp14, %bb11 ], [ 25, %bb190 ]
+ %tmp9 = phi i8 [ %tmp12, %bb11 ], [ 25, %bb190 ]
+ %tmp10 = add i8 %tmp, -5
+ indirectbr i8* undef, [label %bb11, label %bb15]
+
+bb11: ; preds = %bb8
+ %tmp12 = add i8 %tmp9, 1
+ %tmp13 = add i8 %tmp9, -19
+ %tmp14 = add i8 %tmp, 1
+ indirectbr i8* undef, [label %bb8]
+
+bb15: ; preds = %bb8
+ indirectbr i8* undef, [label %bb16]
+
+bb16: ; preds = %bb16, %bb15
+ indirectbr i8* undef, [label %bb37, label %bb190]
+
+
+bb37: ; preds = %bb190
+ indirectbr i8* undef, [label %bb38]
+
+bb38: ; preds = %bb37, %bb5
+ ret void
+
+bb190: ; preds = %bb189, %bb187
+ indirectbr i8* undef, [label %bb37, label %bb8]
+}
More information about the llvm-commits
mailing list