Home | History | Annotate | Download | only in PhaseOrdering
      1 ; RUN: opt -O3 -S < %s | FileCheck %s
      2 ; XFAIL: *
      3 
      4 declare i32 @doo(...)
      5 
      6 ; PR6627 - This whole nasty sequence should be flattened down to a single
      7 ; 32-bit comparison.
      8 define void @test2(i8* %arrayidx) nounwind ssp {
      9 entry:
     10   %xx = bitcast i8* %arrayidx to i32*
     11   %x1 = load i32* %xx, align 4
     12   %tmp = trunc i32 %x1 to i8
     13   %conv = zext i8 %tmp to i32
     14   %cmp = icmp eq i32 %conv, 127
     15   br i1 %cmp, label %land.lhs.true, label %if.end
     16 
     17 land.lhs.true:                                    ; preds = %entry
     18   %arrayidx4 = getelementptr inbounds i8* %arrayidx, i64 1
     19   %tmp5 = load i8* %arrayidx4, align 1
     20   %conv6 = zext i8 %tmp5 to i32
     21   %cmp7 = icmp eq i32 %conv6, 69
     22   br i1 %cmp7, label %land.lhs.true9, label %if.end
     23 
     24 land.lhs.true9:                                   ; preds = %land.lhs.true
     25   %arrayidx12 = getelementptr inbounds i8* %arrayidx, i64 2
     26   %tmp13 = load i8* %arrayidx12, align 1
     27   %conv14 = zext i8 %tmp13 to i32
     28   %cmp15 = icmp eq i32 %conv14, 76
     29   br i1 %cmp15, label %land.lhs.true17, label %if.end
     30 
     31 land.lhs.true17:                                  ; preds = %land.lhs.true9
     32   %arrayidx20 = getelementptr inbounds i8* %arrayidx, i64 3
     33   %tmp21 = load i8* %arrayidx20, align 1
     34   %conv22 = zext i8 %tmp21 to i32
     35   %cmp23 = icmp eq i32 %conv22, 70
     36   br i1 %cmp23, label %if.then, label %if.end
     37 
     38 if.then:                                          ; preds = %land.lhs.true17
     39   %call25 = call i32 (...)* @doo()
     40   br label %if.end
     41 
     42 if.end:
     43   ret void
     44 
     45 ; CHECK-LABEL: @test2(
     46 ; CHECK: %x1 = load i32* %xx, align 4
     47 ; CHECK-NEXT: icmp eq i32 %x1, 1179403647
     48 ; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end 
     49 }
     50 
     51 ; PR6627 - This should all be flattened down to one compare.  This is the same
     52 ; as test2, except that the initial load is done as an i8 instead of i32, thus
     53 ; requiring widening.
     54 define void @test2a(i8* %arrayidx) nounwind ssp {
     55 entry:
     56   %x1 = load i8* %arrayidx, align 4
     57   %conv = zext i8 %x1 to i32
     58   %cmp = icmp eq i32 %conv, 127
     59   br i1 %cmp, label %land.lhs.true, label %if.end
     60 
     61 land.lhs.true:                                    ; preds = %entry
     62   %arrayidx4 = getelementptr inbounds i8* %arrayidx, i64 1
     63   %tmp5 = load i8* %arrayidx4, align 1
     64   %conv6 = zext i8 %tmp5 to i32
     65   %cmp7 = icmp eq i32 %conv6, 69
     66   br i1 %cmp7, label %land.lhs.true9, label %if.end
     67 
     68 land.lhs.true9:                                   ; preds = %land.lhs.true
     69   %arrayidx12 = getelementptr inbounds i8* %arrayidx, i64 2
     70   %tmp13 = load i8* %arrayidx12, align 1
     71   %conv14 = zext i8 %tmp13 to i32
     72   %cmp15 = icmp eq i32 %conv14, 76
     73   br i1 %cmp15, label %land.lhs.true17, label %if.end
     74 
     75 land.lhs.true17:                                  ; preds = %land.lhs.true9
     76   %arrayidx20 = getelementptr inbounds i8* %arrayidx, i64 3
     77   %tmp21 = load i8* %arrayidx20, align 1
     78   %conv22 = zext i8 %tmp21 to i32
     79   %cmp23 = icmp eq i32 %conv22, 70
     80   br i1 %cmp23, label %if.then, label %if.end
     81 
     82 if.then:                                          ; preds = %land.lhs.true17
     83   %call25 = call i32 (...)* @doo()
     84   br label %if.end
     85 
     86 if.end:
     87   ret void
     88 
     89 ; CHECK-LABEL: @test2a(
     90 ; CHECK: %x1 = load i32* {{.*}}, align 4
     91 ; CHECK-NEXT: icmp eq i32 %x1, 1179403647
     92 ; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end 
     93 }
     94