1 ; RUN: llc < %s -march=x86-64 | FileCheck %s 2 3 declare void @bar() 4 5 define void @test1(i32* nocapture %X) nounwind minsize { 6 entry: 7 %tmp1 = load i32, i32* %X, align 4 8 %and = and i32 %tmp1, 255 9 %cmp = icmp eq i32 %and, 47 10 br i1 %cmp, label %if.then, label %if.end 11 12 if.then: 13 tail call void @bar() nounwind 14 br label %if.end 15 16 if.end: 17 ret void 18 ; CHECK-LABEL: test1: 19 ; CHECK: cmpb $47, (%{{rdi|rcx}}) 20 } 21 22 define void @test2(i32 %X) nounwind minsize { 23 entry: 24 %and = and i32 %X, 255 25 %cmp = icmp eq i32 %and, 47 26 br i1 %cmp, label %if.then, label %if.end 27 28 if.then: 29 tail call void @bar() nounwind 30 br label %if.end 31 32 if.end: 33 ret void 34 ; CHECK-LABEL: test2: 35 ; CHECK: cmpb $47, %{{dil|cl}} 36 } 37 38 define void @test3(i32 %X) nounwind minsize { 39 entry: 40 %and = and i32 %X, 255 41 %cmp = icmp eq i32 %and, 255 42 br i1 %cmp, label %if.then, label %if.end 43 44 if.then: 45 tail call void @bar() nounwind 46 br label %if.end 47 48 if.end: 49 ret void 50 ; CHECK-LABEL: test3: 51 ; CHECK: cmpb $-1, %{{dil|cl}} 52 } 53 54 ; PR16083 55 define i1 @test4(i64 %a, i32 %b) { 56 entry: 57 %tobool = icmp ne i32 %b, 0 58 br i1 %tobool, label %lor.end, label %lor.rhs 59 60 lor.rhs: ; preds = %entry 61 %and = and i64 0, %a 62 %tobool1 = icmp ne i64 %and, 0 63 br label %lor.end 64 65 lor.end: ; preds = %lor.rhs, %entry 66 %p = phi i1 [ true, %entry ], [ %tobool1, %lor.rhs ] 67 ret i1 %p 68 } 69 70 @x = global { i8, i8, i8, i8, i8, i8, i8, i8 } { i8 1, i8 0, i8 0, i8 0, i8 1, i8 0, i8 0, i8 1 }, align 4 71 72 ; PR16551 73 define void @test5(i32 %X) nounwind minsize { 74 entry: 75 %bf.load = load i56, i56* bitcast ({ i8, i8, i8, i8, i8, i8, i8, i8 }* @x to i56*), align 4 76 %bf.lshr = lshr i56 %bf.load, 32 77 %bf.cast = trunc i56 %bf.lshr to i32 78 %cmp = icmp ne i32 %bf.cast, 1 79 br i1 %cmp, label %if.then, label %if.end 80 81 if.then: 82 tail call void @bar() nounwind 83 br label %if.end 84 85 if.end: 86 ret void 87 88 ; CHECK-LABEL: test5: 89 ; CHECK-NOT: cmpl $1,{{.*}}x+4 90 ; CHECK: ret 91 } 92 93 ; CHECK-LABEL: test2_1: 94 ; CHECK: movzbl 95 ; CHECK: cmpl $256 96 ; CHECK: jne 97 define void @test2_1(i32 %X) nounwind minsize { 98 entry: 99 %and = and i32 %X, 255 100 %cmp = icmp eq i32 %and, 256 101 br i1 %cmp, label %if.then, label %if.end 102 103 if.then: 104 tail call void @bar() nounwind 105 br label %if.end 106 107 if.end: 108 ret void 109 } 110 111 ; CHECK-LABEL: test_sext_i8_icmp_1: 112 ; CHECK: cmpb $1, %{{dil|cl}} 113 define void @test_sext_i8_icmp_1(i8 %x) nounwind minsize { 114 entry: 115 %sext = sext i8 %x to i32 116 %cmp = icmp eq i32 %sext, 1 117 br i1 %cmp, label %if.then, label %if.end 118 119 if.then: 120 tail call void @bar() nounwind 121 br label %if.end 122 123 if.end: 124 ret void 125 } 126 127 ; CHECK-LABEL: test_sext_i8_icmp_47: 128 ; CHECK: cmpb $47, %{{dil|cl}} 129 define void @test_sext_i8_icmp_47(i8 %x) nounwind minsize { 130 entry: 131 %sext = sext i8 %x to i32 132 %cmp = icmp eq i32 %sext, 47 133 br i1 %cmp, label %if.then, label %if.end 134 135 if.then: 136 tail call void @bar() nounwind 137 br label %if.end 138 139 if.end: 140 ret void 141 } 142 143 ; CHECK-LABEL: test_sext_i8_icmp_127: 144 ; CHECK: cmpb $127, %{{dil|cl}} 145 define void @test_sext_i8_icmp_127(i8 %x) nounwind minsize { 146 entry: 147 %sext = sext i8 %x to i32 148 %cmp = icmp eq i32 %sext, 127 149 br i1 %cmp, label %if.then, label %if.end 150 151 if.then: 152 tail call void @bar() nounwind 153 br label %if.end 154 155 if.end: 156 ret void 157 } 158 159 ; CHECK-LABEL: test_sext_i8_icmp_neg1: 160 ; CHECK: cmpb $-1, %{{dil|cl}} 161 define void @test_sext_i8_icmp_neg1(i8 %x) nounwind minsize { 162 entry: 163 %sext = sext i8 %x to i32 164 %cmp = icmp eq i32 %sext, -1 165 br i1 %cmp, label %if.then, label %if.end 166 167 if.then: 168 tail call void @bar() nounwind 169 br label %if.end 170 171 if.end: 172 ret void 173 } 174 175 ; CHECK-LABEL: test_sext_i8_icmp_neg2: 176 ; CHECK: cmpb $-2, %{{dil|cl}} 177 define void @test_sext_i8_icmp_neg2(i8 %x) nounwind minsize { 178 entry: 179 %sext = sext i8 %x to i32 180 %cmp = icmp eq i32 %sext, -2 181 br i1 %cmp, label %if.then, label %if.end 182 183 if.then: 184 tail call void @bar() nounwind 185 br label %if.end 186 187 if.end: 188 ret void 189 } 190 191 ; CHECK-LABEL: test_sext_i8_icmp_neg127: 192 ; CHECK: cmpb $-127, %{{dil|cl}} 193 define void @test_sext_i8_icmp_neg127(i8 %x) nounwind minsize { 194 entry: 195 %sext = sext i8 %x to i32 196 %cmp = icmp eq i32 %sext, -127 197 br i1 %cmp, label %if.then, label %if.end 198 199 if.then: 200 tail call void @bar() nounwind 201 br label %if.end 202 203 if.end: 204 ret void 205 } 206 207 ; CHECK-LABEL: test_sext_i8_icmp_neg128: 208 ; CHECK: cmpb $-128, %{{dil|cl}} 209 define void @test_sext_i8_icmp_neg128(i8 %x) nounwind minsize { 210 entry: 211 %sext = sext i8 %x to i32 212 %cmp = icmp eq i32 %sext, -128 213 br i1 %cmp, label %if.then, label %if.end 214 215 if.then: 216 tail call void @bar() nounwind 217 br label %if.end 218 219 if.end: 220 ret void 221 } 222 223 ; CHECK-LABEL: test_sext_i8_icmp_255: 224 ; CHECK: movb $1, 225 ; CHECK: testb 226 ; CHECK: jne 227 define void @test_sext_i8_icmp_255(i8 %x) nounwind minsize { 228 entry: 229 %sext = sext i8 %x to i32 230 %cmp = icmp eq i32 %sext, 255 231 br i1 %cmp, label %if.then, label %if.end 232 233 if.then: 234 tail call void @bar() nounwind 235 br label %if.end 236 237 if.end: 238 ret void 239 } 240