first step to fixing PR8642: don't fold away empty basic blocks
[oota-llvm.git] / test / Transforms / CodeGenPrepare / basic.ll
1 ; RUN: opt -codegenprepare %s -S | FileCheck %s
2 ; PR8642
3
4 %0 = type <{ %1, %1 }>
5 %1 = type { i8, i8, i8, i8 }
6
7 @g_2 = global %0 <{ %1 { i8 1, i8 0, i8 0, i8 undef }, %1 { i8 2, i8 0, i8 0, i8 undef } }>, align 4
8 @g_4 = global %1 { i8 3, i8 0, i8 0, i8 undef }, align 4
9
10 ; CGP shouldn't fold away the empty cond.false.i block, because the constant
11 ; expr that will get dropped into it could trap.
12 define i16 @test1(i8** %argv, i1 %c) nounwind ssp {
13 entry:
14   br i1 %c, label %cond.end.i, label %cond.false.i
15
16 cond.false.i:                                     ; preds = %entry
17   br label %foo.exit
18
19 cond.end.i:                                       ; preds = %entry
20   store i8* null, i8** %argv
21   br label %foo.exit
22
23 foo.exit:                                         ; preds = %cond.end.i, %cond.false.i
24   %call1 = phi i16 [ trunc (i32 srem (i32 1, i32 zext (i1 icmp eq (%1* bitcast (i8* getelementptr inbounds (%0* @g_2, i64 0, i32 1, i32 0) to %1*), %1* @g_4) to i32)) to i16), %cond.false.i ], [ 1, %cond.end.i ]
25   ret i16 %call1
26   
27 ; CHECK: @test1
28 ; CHECK: cond.false.i:
29 ; CHECK-NEXT:  br label %foo.exit
30 }
31