Home | History | Annotate | Download | only in SimplifyCFG
      1 ; RUN: opt < %s -simplifycfg -S | FileCheck %s
      2 ; PR3354
      3 ; Do not merge bb1 into the entry block, it might trap.
      4 
      5 @G = extern_weak global i32
      6 
      7 ; CHECK-LABEL: @test(
      8 ; CHECK: br i1 %tmp25
      9 ; CHECK: bb1:
     10 ; CHECK: sdiv
     11 
     12 define i32 @test(i32 %tmp21, i32 %tmp24) {
     13 	%tmp25 = icmp sle i32 %tmp21, %tmp24		
     14 	br i1 %tmp25, label %bb2, label %bb1	
     15 					
     16 bb1:		; preds = %bb	
     17 	%tmp26 = icmp sgt i32 sdiv (i32 -32768, i32 ptrtoint (i32* @G to i32)), 0
     18 	br i1 %tmp26, label %bb6, label %bb2		
     19 bb2:
     20 	ret i32 42
     21 
     22 bb6:
     23 	ret i32 927
     24 }
     25 
     26 ; CHECK-LABEL: @test2(
     27 ; CHECK: br i1 %tmp34
     28 ; CHECK: bb5:
     29 ; CHECK: sdiv
     30 
     31 define i32 @test2(i32 %tmp21, i32 %tmp24, i1 %tmp34) {
     32 	br i1 %tmp34, label %bb5, label %bb6
     33 
     34 bb5:		; preds = %bb4
     35 	br i1 icmp sgt (i32 sdiv (i32 32767, i32 ptrtoint (i32* @G to i32)), i32 0), label %bb6, label %bb7
     36 bb6:
     37 	ret i32 42
     38 bb7:
     39 	ret i32 927
     40 }
     41 
     42