Home | History | Annotate | Download | only in X86
      1 ; RUN: llc -mtriple=x86_64-apple-darwin < %s | FileCheck %s
      2 
      3 @.str2 = private unnamed_addr constant [7 x i8] c"memchr\00", align 1
      4 @.str3 = private unnamed_addr constant [11 x i8] c"bsd_memchr\00", align 1
      5 @str4 = private unnamed_addr constant [5 x i8] c"Bug!\00"
      6 
      7 ; Make sure at end of do.cond.i, we jump to do.body.i first to have a tighter
      8 ; inner loop.
      9 define i32 @test_branches_order() uwtable ssp {
     10 ; CHECK-LABEL: test_branches_order:
     11 ; CHECK: [[L0:LBB0_[0-9]+]]: ## %do.body.i
     12 ; CHECK: je
     13 ; CHECK: %do.cond.i
     14 ; CHECK: jne [[L0]]
     15 ; CHECK: jmp
     16 ; CHECK: %exit
     17 entry:
     18   %strs = alloca [1000 x [1001 x i8]], align 16
     19   br label %for.cond
     20 
     21 for.cond:
     22   %j.0 = phi i32 [ 0, %entry ], [ %inc10, %for.inc9 ]
     23   %cmp = icmp slt i32 %j.0, 1000
     24   br i1 %cmp, label %for.cond1, label %for.end11
     25 
     26 for.cond1:
     27   %indvars.iv50 = phi i64 [ %indvars.iv.next51, %for.body3 ], [ 0, %for.cond ]
     28   %0 = trunc i64 %indvars.iv50 to i32
     29   %cmp2 = icmp slt i32 %0, 1000
     30   br i1 %cmp2, label %for.body3, label %for.inc9
     31 
     32 for.body3:
     33   %arraydecay = getelementptr inbounds [1000 x [1001 x i8]]* %strs, i64 0, i64 %indvars.iv50, i64 0
     34   %call = call i8* @memchr(i8* %arraydecay, i32 120, i64 1000)
     35   %add.ptr = getelementptr inbounds [1000 x [1001 x i8]]* %strs, i64 0, i64 %indvars.iv50, i64 %indvars.iv50
     36   %cmp7 = icmp eq i8* %call, %add.ptr
     37   %indvars.iv.next51 = add i64 %indvars.iv50, 1
     38   br i1 %cmp7, label %for.cond1, label %if.then
     39 
     40 if.then:
     41   %puts = call i32 @puts(i8* getelementptr inbounds ([5 x i8]* @str4, i64 0, i64 0))
     42   call void @exit(i32 1) noreturn
     43   unreachable
     44 
     45 for.inc9:
     46   %inc10 = add nsw i32 %j.0, 1
     47   br label %for.cond
     48 
     49 for.end11:
     50   %puts42 = call i32 @puts(i8* getelementptr inbounds ([7 x i8]* @.str2, i64 0, i64 0))
     51   br label %for.cond14
     52 
     53 for.cond14:
     54   %j13.0 = phi i32 [ 0, %for.end11 ], [ %inc39, %for.inc38 ]
     55   %cmp15 = icmp slt i32 %j13.0, 1000
     56   br i1 %cmp15, label %for.cond18, label %for.end40
     57 
     58 for.cond18:
     59   %indvars.iv = phi i64 [ %indvars.iv.next, %exit ], [ 0, %for.cond14 ]
     60   %1 = trunc i64 %indvars.iv to i32
     61   %cmp19 = icmp slt i32 %1, 1000
     62   br i1 %cmp19, label %for.body20, label %for.inc38
     63 
     64 for.body20:
     65   %arraydecay24 = getelementptr inbounds [1000 x [1001 x i8]]* %strs, i64 0, i64 %indvars.iv, i64 0
     66   br label %do.body.i
     67 
     68 do.body.i:
     69   %n.addr.0.i = phi i64 [ %dec.i, %do.cond.i ], [ 1000, %for.body20 ]
     70   %p.0.i = phi i8* [ %incdec.ptr.i, %do.cond.i ], [ %arraydecay24, %for.body20 ]
     71   %2 = load i8* %p.0.i, align 1
     72   %cmp3.i = icmp eq i8 %2, 120
     73   br i1 %cmp3.i, label %exit, label %do.cond.i
     74 
     75 do.cond.i:
     76   %incdec.ptr.i = getelementptr inbounds i8* %p.0.i, i64 1
     77   %dec.i = add i64 %n.addr.0.i, -1
     78   %cmp5.i = icmp eq i64 %dec.i, 0
     79   br i1 %cmp5.i, label %if.then32, label %do.body.i
     80 
     81 exit:
     82   %add.ptr30 = getelementptr inbounds [1000 x [1001 x i8]]* %strs, i64 0, i64 %indvars.iv, i64 %indvars.iv
     83   %cmp31 = icmp eq i8* %p.0.i, %add.ptr30
     84   %indvars.iv.next = add i64 %indvars.iv, 1
     85   br i1 %cmp31, label %for.cond18, label %if.then32
     86 
     87 if.then32:
     88   %puts43 = call i32 @puts(i8* getelementptr inbounds ([5 x i8]* @str4, i64 0, i64 0))
     89   call void @exit(i32 1) noreturn
     90   unreachable
     91 
     92 for.inc38:
     93   %inc39 = add nsw i32 %j13.0, 1
     94   br label %for.cond14
     95 
     96 for.end40:
     97   %puts44 = call i32 @puts(i8* getelementptr inbounds ([11 x i8]* @.str3, i64 0, i64 0))
     98   ret i32 0
     99 }
    100 
    101 declare i8* @memchr(i8*, i32, i64) nounwind readonly
    102 declare void @exit(i32) noreturn
    103 declare i32 @puts(i8* nocapture) nounwind
    104 
    105