Home | History | Annotate | Download | only in SimplifyCFG
      1 ; RUN: opt -S -simplifycfg %s | FileCheck %s
      2 
      3 define i8* @test1(i8* %x, i64 %y) nounwind {
      4 entry:
      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 
      9 if.then:
     10   %incdec.ptr = getelementptr inbounds i8* %x, i64 %y
     11   br label %if.end
     12 
     13 if.end:
     14   %x.addr = phi i8* [ %incdec.ptr, %if.then ], [ %x, %entry ]
     15   ret i8* %x.addr
     16 
     17 ; CHECK: @test1
     18 ; CHECK-NOT: select
     19 ; CHECK: ret i8* %x.addr
     20 }
     21 
     22 %ST = type { i8, i8 }
     23 
     24 define i8* @test2(%ST* %x, i8* %y) nounwind {
     25 entry:
     26   %cmp = icmp eq %ST* %x, null
     27   br i1 %cmp, label %if.then, label %if.end
     28 
     29 if.then:
     30   %incdec.ptr = getelementptr %ST* %x, i32 0, i32 1
     31   br label %if.end
     32 
     33 if.end:
     34   %x.addr = phi i8* [ %incdec.ptr, %if.then ], [ %y, %entry ]
     35   ret i8* %x.addr
     36 
     37 ; CHECK: @test2
     38 ; CHECK: %x.addr = select i1 %cmp, i8* %incdec.ptr, i8* %y
     39 ; CHECK: ret i8* %x.addr
     40 }
     41