blob: 7654d0271a9a246f90a52ff4bd98efd9baf95fff [file] [log] [blame]
Benjamin Kramer9b61c552011-02-24 22:46:11 +00001; RUN: opt -S -simplifycfg %s | FileCheck %s
2
Benjamin Kramer9ae59e32011-02-24 23:26:09 +00003define i8* @test1(i8* %x, i64 %y) nounwind {
Benjamin Kramer9b61c552011-02-24 22:46:11 +00004entry:
5 %tmp1 = load i8* %x, align 1
6 %cmp = icmp eq i8 %tmp1, 47
7 br i1 %cmp, label %if.then, label %if.end
8
9if.then:
Benjamin Kramer9ae59e32011-02-24 23:26:09 +000010 %incdec.ptr = getelementptr inbounds i8* %x, i64 %y
Benjamin Kramer9b61c552011-02-24 22:46:11 +000011 br label %if.end
12
13if.end:
14 %x.addr = phi i8* [ %incdec.ptr, %if.then ], [ %x, %entry ]
15 ret i8* %x.addr
16
17; CHECK: @test1
Benjamin Kramer278be782011-02-25 10:33:33 +000018; CHECK-NOT: select
Benjamin Kramer9b61c552011-02-24 22:46:11 +000019; CHECK: ret i8* %x.addr
20}
Benjamin Kramer9ae59e32011-02-24 23:26:09 +000021
22%ST = type { i8, i8 }
23
24define i8* @test2(%ST* %x, i8* %y) nounwind {
25entry:
26 %cmp = icmp eq %ST* %x, null
27 br i1 %cmp, label %if.then, label %if.end
28
29if.then:
30 %incdec.ptr = getelementptr %ST* %x, i32 0, i32 1
31 br label %if.end
32
33if.end:
34 %x.addr = phi i8* [ %incdec.ptr, %if.then ], [ %y, %entry ]
35 ret i8* %x.addr
36
37; CHECK: @test2
Dan Gohman3b205172012-01-05 23:58:56 +000038; CHECK: %incdec.ptr.y = select i1 %cmp, i8* %incdec.ptr, i8* %y
39; CHECK: ret i8* %incdec.ptr.y
Benjamin Kramer9ae59e32011-02-24 23:26:09 +000040}