1 ; RUN: opt < %s -codegenprepare -S -mtriple=x86_64-unknown-unknown | FileCheck %s
4 @a = global [10 x i8] zeroinitializer, align 1
7 ; ext(and(ld, cst)) -> and(ext(ld), ext(cst))
8 define void @test1(ptr %p, i32 %ll) {
15 %tmp = load i8, ptr @a, align 1
16 %and = and i8 %tmp, 60
17 %cmp = icmp ugt i8 %and, 20
18 br i1 %cmp, label %if.then, label %if.end
20 if.then: ; preds = %entry
21 %conv2 = zext i8 %and to i32
22 %add = add nsw i32 %conv2, %ll
23 store i32 %add, ptr %p, align 4
26 if.end: ; preds = %if.then, %entry
31 ; ext(or(ld, cst)) -> or(ext(ld), ext(cst))
32 define void @test2(ptr %p, i32 %ll) {
39 %tmp = load i8, ptr @a, align 1
41 %cmp = icmp ugt i8 %or, 20
42 br i1 %cmp, label %if.then, label %if.end
44 if.then: ; preds = %entry
45 %conv2 = zext i8 %or to i32
46 %add = add nsw i32 %conv2, %ll
47 store i32 %add, ptr %p, align 4
50 if.end: ; preds = %if.then, %entry
55 ; ext(and(shl(ld, cst), cst)) -> and(shl(ext(ld), ext(cst)), ext(cst))
56 define void @test3(ptr %p, i32 %ll) {
64 %tmp = load i8, ptr @a, align 1
66 %and = and i8 %shl, 60
67 %cmp = icmp ugt i8 %and, 20
68 br i1 %cmp, label %if.then, label %if.end
70 if.then: ; preds = %entry
71 %conv2 = zext i8 %and to i32
72 %add = add nsw i32 %conv2, %ll
73 store i32 %add, ptr %p, align 4
76 if.end: ; preds = %if.then, %entry
81 ; zext(shrl(ld, cst)) -> shrl(zext(ld), zext(cst))
82 define void @test4(ptr %p, i32 %ll) {
89 %tmp = load i8, ptr @a, align 1
90 %lshr = lshr i8 %tmp, 2
91 %cmp = icmp ugt i8 %lshr, 20
92 br i1 %cmp, label %if.then, label %if.end
94 if.then: ; preds = %entry
95 %conv2 = zext i8 %lshr to i32
96 %add = add nsw i32 %conv2, %ll
97 store i32 %add, ptr %p, align 4
100 if.end: ; preds = %if.then, %entry
101 tail call void @foo()
105 ; ext(xor(ld, cst)) -> xor(ext(ld), ext(cst))
106 define void @test5(ptr %p, i32 %ll) {
107 ; CHECK-LABEL: @test5
113 %tmp = load i8, ptr @a, align 1
114 %xor = xor i8 %tmp, 60
115 %cmp = icmp ugt i8 %xor, 20
116 br i1 %cmp, label %if.then, label %if.end
118 if.then: ; preds = %entry
119 %conv2 = zext i8 %xor to i32
120 %add = add nsw i32 %conv2, %ll
121 store i32 %add, ptr %p, align 4
124 if.end: ; preds = %if.then, %entry
125 tail call void @foo()