blob: aac0d319ae84c70688a4fe86a108e5ddac6f2689 [file] [log] [blame]
Andrew Trick9093e152013-03-26 03:14:53 +00001; RUN: opt < %s -S -indvars -loop-unroll | FileCheck %s
2;
3; PR15570: SEGV: SCEV back-edge info invalid after dead code removal.
4;
5; Indvars creates a SCEV expression for the loop's back edge taken
6; count, then determines that the comparison is always true and
7; removes it.
8;
9; When loop-unroll asks for the expression, it contains a NULL
10; SCEVUnknkown (as a CallbackVH).
11;
12; forgetMemoizedResults should invalidate the backedge taken count expression.
13
14; CHECK: @test
15; CHECK-NOT: phi
16; CHECK-NOT: icmp
17; CHECK: ret void
18define void @test() {
19entry:
20 %xor1 = xor i32 0, 1
21 br label %b17
22
23b17:
24 br i1 undef, label %b22, label %b18
25
26b18:
27 %phi1 = phi i32 [ %add1, %b18 ], [ %xor1, %b17 ]
28 %add1 = add nsw i32 %phi1, -1
29 %cmp1 = icmp sgt i32 %add1, 0
30 br i1 %cmp1, label %b18, label %b22
31
32b22:
33 ret void
34}