Home | History | Annotate | Download | only in Generic
      1 ; RUN: llc < %s
      2 
      3 define i32 @test1(i32 %x) nounwind uwtable ssp {
      4 entry:
      5   %retval = alloca i32, align 4
      6   %x.addr = alloca i32, align 4
      7   store i32 %x, i32* %x.addr, align 4
      8   %tmp = load i32* %x.addr, align 4
      9   %cmp = icmp sgt i32 %tmp, 1
     10   %conv = zext i1 %cmp to i32
     11   %conv1 = sext i32 %conv to i64
     12   %expval = call i64 @llvm.expect.i64(i64 %conv1, i64 1)
     13   %tobool = icmp ne i64 %expval, 0
     14   br i1 %tobool, label %if.then, label %if.end
     15 
     16 if.then:                                          ; preds = %entry
     17   %call = call i32 (...)* @f()
     18   store i32 %call, i32* %retval
     19   br label %return
     20 
     21 if.end:                                           ; preds = %entry
     22   store i32 1, i32* %retval
     23   br label %return
     24 
     25 return:                                           ; preds = %if.end, %if.then
     26   %0 = load i32* %retval
     27   ret i32 %0
     28 }
     29 
     30 declare i64 @llvm.expect.i64(i64, i64) nounwind readnone
     31 
     32 declare i32 @f(...)
     33 
     34 define i32 @test2(i32 %x) nounwind uwtable ssp {
     35 entry:
     36   %retval = alloca i32, align 4
     37   %x.addr = alloca i32, align 4
     38   store i32 %x, i32* %x.addr, align 4
     39   %tmp = load i32* %x.addr, align 4
     40   %conv = sext i32 %tmp to i64
     41   %expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
     42   %tobool = icmp ne i64 %expval, 0
     43   br i1 %tobool, label %if.then, label %if.end
     44 
     45 if.then:                                          ; preds = %entry
     46   %call = call i32 (...)* @f()
     47   store i32 %call, i32* %retval
     48   br label %return
     49 
     50 if.end:                                           ; preds = %entry
     51   store i32 1, i32* %retval
     52   br label %return
     53 
     54 return:                                           ; preds = %if.end, %if.then
     55   %0 = load i32* %retval
     56   ret i32 %0
     57 }
     58 
     59 define i32 @test3(i32 %x) nounwind uwtable ssp {
     60 entry:
     61   %retval = alloca i32, align 4
     62   %x.addr = alloca i32, align 4
     63   store i32 %x, i32* %x.addr, align 4
     64   %tmp = load i32* %x.addr, align 4
     65   %tobool = icmp ne i32 %tmp, 0
     66   %lnot = xor i1 %tobool, true
     67   %lnot.ext = zext i1 %lnot to i32
     68   %conv = sext i32 %lnot.ext to i64
     69   %expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
     70   %tobool1 = icmp ne i64 %expval, 0
     71   br i1 %tobool1, label %if.then, label %if.end
     72 
     73 if.then:                                          ; preds = %entry
     74   %call = call i32 (...)* @f()
     75   store i32 %call, i32* %retval
     76   br label %return
     77 
     78 if.end:                                           ; preds = %entry
     79   store i32 1, i32* %retval
     80   br label %return
     81 
     82 return:                                           ; preds = %if.end, %if.then
     83   %0 = load i32* %retval
     84   ret i32 %0
     85 }
     86 
     87 define i32 @test4(i32 %x) nounwind uwtable ssp {
     88 entry:
     89   %retval = alloca i32, align 4
     90   %x.addr = alloca i32, align 4
     91   store i32 %x, i32* %x.addr, align 4
     92   %tmp = load i32* %x.addr, align 4
     93   %tobool = icmp ne i32 %tmp, 0
     94   %lnot = xor i1 %tobool, true
     95   %lnot1 = xor i1 %lnot, true
     96   %lnot.ext = zext i1 %lnot1 to i32
     97   %conv = sext i32 %lnot.ext to i64
     98   %expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
     99   %tobool2 = icmp ne i64 %expval, 0
    100   br i1 %tobool2, label %if.then, label %if.end
    101 
    102 if.then:                                          ; preds = %entry
    103   %call = call i32 (...)* @f()
    104   store i32 %call, i32* %retval
    105   br label %return
    106 
    107 if.end:                                           ; preds = %entry
    108   store i32 1, i32* %retval
    109   br label %return
    110 
    111 return:                                           ; preds = %if.end, %if.then
    112   %0 = load i32* %retval
    113   ret i32 %0
    114 }
    115 
    116 define i32 @test5(i32 %x) nounwind uwtable ssp {
    117 entry:
    118   %retval = alloca i32, align 4
    119   %x.addr = alloca i32, align 4
    120   store i32 %x, i32* %x.addr, align 4
    121   %tmp = load i32* %x.addr, align 4
    122   %cmp = icmp slt i32 %tmp, 0
    123   %conv = zext i1 %cmp to i32
    124   %conv1 = sext i32 %conv to i64
    125   %expval = call i64 @llvm.expect.i64(i64 %conv1, i64 0)
    126   %tobool = icmp ne i64 %expval, 0
    127   br i1 %tobool, label %if.then, label %if.end
    128 
    129 if.then:                                          ; preds = %entry
    130   %call = call i32 (...)* @f()
    131   store i32 %call, i32* %retval
    132   br label %return
    133 
    134 if.end:                                           ; preds = %entry
    135   store i32 1, i32* %retval
    136   br label %return
    137 
    138 return:                                           ; preds = %if.end, %if.then
    139   %0 = load i32* %retval
    140   ret i32 %0
    141 }
    142 
    143 define i32 @test6(i32 %x) nounwind uwtable ssp {
    144 entry:
    145   %retval = alloca i32, align 4
    146   %x.addr = alloca i32, align 4
    147   store i32 %x, i32* %x.addr, align 4
    148   %tmp = load i32* %x.addr, align 4
    149   %conv = sext i32 %tmp to i64
    150   %expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
    151   switch i64 %expval, label %sw.epilog [
    152     i64 1, label %sw.bb
    153     i64 2, label %sw.bb
    154   ]
    155 
    156 sw.bb:                                            ; preds = %entry, %entry
    157   store i32 0, i32* %retval
    158   br label %return
    159 
    160 sw.epilog:                                        ; preds = %entry
    161   store i32 1, i32* %retval
    162   br label %return
    163 
    164 return:                                           ; preds = %sw.epilog, %sw.bb
    165   %0 = load i32* %retval
    166   ret i32 %0
    167 }
    168 
    169 define i32 @test7(i32 %x) nounwind uwtable ssp {
    170 entry:
    171   %retval = alloca i32, align 4
    172   %x.addr = alloca i32, align 4
    173   store i32 %x, i32* %x.addr, align 4
    174   %tmp = load i32* %x.addr, align 4
    175   %conv = sext i32 %tmp to i64
    176   %expval = call i64 @llvm.expect.i64(i64 %conv, i64 1)
    177   switch i64 %expval, label %sw.epilog [
    178     i64 2, label %sw.bb
    179     i64 3, label %sw.bb
    180   ]
    181 
    182 sw.bb:                                            ; preds = %entry, %entry
    183   %tmp1 = load i32* %x.addr, align 4
    184   store i32 %tmp1, i32* %retval
    185   br label %return
    186 
    187 sw.epilog:                                        ; preds = %entry
    188   store i32 0, i32* %retval
    189   br label %return
    190 
    191 return:                                           ; preds = %sw.epilog, %sw.bb
    192   %0 = load i32* %retval
    193   ret i32 %0
    194 }
    195 
    196 define i32 @test8(i32 %x) nounwind uwtable ssp {
    197 entry:
    198   %retval = alloca i32, align 4
    199   %x.addr = alloca i32, align 4
    200   store i32 %x, i32* %x.addr, align 4
    201   %tmp = load i32* %x.addr, align 4
    202   %cmp = icmp sgt i32 %tmp, 1
    203   %conv = zext i1 %cmp to i32
    204   %expval = call i32 @llvm.expect.i32(i32 %conv, i32 1)
    205   %tobool = icmp ne i32 %expval, 0
    206   br i1 %tobool, label %if.then, label %if.end
    207 
    208 if.then:                                          ; preds = %entry
    209   %call = call i32 (...)* @f()
    210   store i32 %call, i32* %retval
    211   br label %return
    212 
    213 if.end:                                           ; preds = %entry
    214   store i32 1, i32* %retval
    215   br label %return
    216 
    217 return:                                           ; preds = %if.end, %if.then
    218   %0 = load i32* %retval
    219   ret i32 %0
    220 }
    221 
    222 declare i32 @llvm.expect.i32(i32, i32) nounwind readnone
    223 
    224