Home | History | Annotate | Download | only in PhaseOrdering
      1 ; RUN: opt -O3 -S %s | FileCheck %s
      2 ; XFAIL: *
      3 
      4 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
      5 target triple = "x86_64-apple-macosx10.6.7"
      6 
      7 declare i8* @malloc(i64)
      8 declare void @free(i8*)
      9 
     10 
     11 ; PR2338
     12 define void @test1() nounwind ssp {
     13   %retval = alloca i32, align 4
     14   %i = alloca i8*, align 8
     15   %call = call i8* @malloc(i64 1)
     16   store i8* %call, i8** %i, align 8
     17   %tmp = load i8** %i, align 8
     18   store i8 1, i8* %tmp
     19   %tmp1 = load i8** %i, align 8
     20   call void @free(i8* %tmp1)
     21   ret void
     22 
     23 ; CHECK: @test1
     24 ; CHECK-NEXT: ret void
     25 }
     26 
     27 
     28 ; PR6627 - This whole nasty sequence should be flattened down to a single
     29 ; 32-bit comparison.
     30 define void @test2(i8* %arrayidx) nounwind ssp {
     31 entry:
     32   %xx = bitcast i8* %arrayidx to i32*
     33   %x1 = load i32* %xx, align 4
     34   %tmp = trunc i32 %x1 to i8
     35   %conv = zext i8 %tmp to i32
     36   %cmp = icmp eq i32 %conv, 127
     37   br i1 %cmp, label %land.lhs.true, label %if.end
     38 
     39 land.lhs.true:                                    ; preds = %entry
     40   %arrayidx4 = getelementptr inbounds i8* %arrayidx, i64 1
     41   %tmp5 = load i8* %arrayidx4, align 1
     42   %conv6 = zext i8 %tmp5 to i32
     43   %cmp7 = icmp eq i32 %conv6, 69
     44   br i1 %cmp7, label %land.lhs.true9, label %if.end
     45 
     46 land.lhs.true9:                                   ; preds = %land.lhs.true
     47   %arrayidx12 = getelementptr inbounds i8* %arrayidx, i64 2
     48   %tmp13 = load i8* %arrayidx12, align 1
     49   %conv14 = zext i8 %tmp13 to i32
     50   %cmp15 = icmp eq i32 %conv14, 76
     51   br i1 %cmp15, label %land.lhs.true17, label %if.end
     52 
     53 land.lhs.true17:                                  ; preds = %land.lhs.true9
     54   %arrayidx20 = getelementptr inbounds i8* %arrayidx, i64 3
     55   %tmp21 = load i8* %arrayidx20, align 1
     56   %conv22 = zext i8 %tmp21 to i32
     57   %cmp23 = icmp eq i32 %conv22, 70
     58   br i1 %cmp23, label %if.then, label %if.end
     59 
     60 if.then:                                          ; preds = %land.lhs.true17
     61   %call25 = call i32 (...)* @doo()
     62   br label %if.end
     63 
     64 if.end:
     65   ret void
     66 
     67 ; CHECK: @test2
     68 ; CHECK: %x1 = load i32* %xx, align 4
     69 ; CHECK-NEXT: icmp eq i32 %x1, 1179403647
     70 ; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end 
     71 }
     72 
     73 declare i32 @doo(...)
     74 
     75 ; PR6627 - This should all be flattened down to one compare.  This is the same
     76 ; as test2, except that the initial load is done as an i8 instead of i32, thus
     77 ; requiring widening.
     78 define void @test2a(i8* %arrayidx) nounwind ssp {
     79 entry:
     80   %x1 = load i8* %arrayidx, align 4
     81   %conv = zext i8 %x1 to i32
     82   %cmp = icmp eq i32 %conv, 127
     83   br i1 %cmp, label %land.lhs.true, label %if.end
     84 
     85 land.lhs.true:                                    ; preds = %entry
     86   %arrayidx4 = getelementptr inbounds i8* %arrayidx, i64 1
     87   %tmp5 = load i8* %arrayidx4, align 1
     88   %conv6 = zext i8 %tmp5 to i32
     89   %cmp7 = icmp eq i32 %conv6, 69
     90   br i1 %cmp7, label %land.lhs.true9, label %if.end
     91 
     92 land.lhs.true9:                                   ; preds = %land.lhs.true
     93   %arrayidx12 = getelementptr inbounds i8* %arrayidx, i64 2
     94   %tmp13 = load i8* %arrayidx12, align 1
     95   %conv14 = zext i8 %tmp13 to i32
     96   %cmp15 = icmp eq i32 %conv14, 76
     97   br i1 %cmp15, label %land.lhs.true17, label %if.end
     98 
     99 land.lhs.true17:                                  ; preds = %land.lhs.true9
    100   %arrayidx20 = getelementptr inbounds i8* %arrayidx, i64 3
    101   %tmp21 = load i8* %arrayidx20, align 1
    102   %conv22 = zext i8 %tmp21 to i32
    103   %cmp23 = icmp eq i32 %conv22, 70
    104   br i1 %cmp23, label %if.then, label %if.end
    105 
    106 if.then:                                          ; preds = %land.lhs.true17
    107   %call25 = call i32 (...)* @doo()
    108   br label %if.end
    109 
    110 if.end:
    111   ret void
    112 
    113 ; CHECK: @test2a
    114 ; CHECK: %x1 = load i32* {{.*}}, align 4
    115 ; CHECK-NEXT: icmp eq i32 %x1, 1179403647
    116 ; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end 
    117 }
    118 
    119