OLD | NEW |
(Empty) | |
| 1 ; Tests various aspects of i1 related lowering. |
| 2 |
| 3 ; RUN: %llvm2ice -O2 --verbose none %s \ |
| 4 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \ |
| 5 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s |
| 6 ; RUN: %llvm2ice -Om1 --verbose none %s \ |
| 7 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj \ |
| 8 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s |
| 9 ; RUN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s |
| 10 ; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s |
| 11 ; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \ |
| 12 ; RUN: | FileCheck --check-prefix=DUMP %s |
| 13 |
| 14 ; Test that xor with true uses immediate 1, not -1. |
| 15 define internal i32 @testXorTrue(i32 %arg) { |
| 16 entry: |
| 17 %arg_i1 = trunc i32 %arg to i1 |
| 18 %result_i1 = xor i1 %arg_i1, true |
| 19 %result = zext i1 %result_i1 to i32 |
| 20 ret i32 %result |
| 21 } |
| 22 ; CHECK-LABEL: testXorTrue |
| 23 ; CHECK: xor {{.*}}, 1 |
| 24 |
| 25 ; Test that trunc to i1 masks correctly. |
| 26 define internal i32 @testTrunc(i32 %arg) { |
| 27 entry: |
| 28 %arg_i1 = trunc i32 %arg to i1 |
| 29 %result = zext i1 %arg_i1 to i32 |
| 30 ret i32 %result |
| 31 } |
| 32 ; CHECK-LABEL: testTrunc |
| 33 ; CHECK: and {{.*}}, 1 |
| 34 |
| 35 ; Test zext to i8. |
| 36 define internal i32 @testZextI8(i32 %arg) { |
| 37 entry: |
| 38 %arg_i1 = trunc i32 %arg to i1 |
| 39 %result_i8 = zext i1 %arg_i1 to i8 |
| 40 %result = zext i8 %result_i8 to i32 |
| 41 ret i32 %result |
| 42 } |
| 43 ; CHECK-LABEL: testZextI8 |
| 44 ; match the trunc instruction |
| 45 ; CHECK: and {{.*}}, 1 |
| 46 ; match the zext i1 instruction |
| 47 ; CHECK: movzx |
| 48 ; CHECK: and {{.*}}, 1 |
| 49 |
| 50 ; Test zext to i16. |
| 51 define internal i32 @testZextI16(i32 %arg) { |
| 52 entry: |
| 53 %arg_i1 = trunc i32 %arg to i1 |
| 54 %result_i16 = zext i1 %arg_i1 to i16 |
| 55 %result = zext i16 %result_i16 to i32 |
| 56 ret i32 %result |
| 57 } |
| 58 ; CHECK-LABEL: testZextI16 |
| 59 ; match the trunc instruction |
| 60 ; CHECK: and {{.*}}, 1 |
| 61 ; match the zext i1 instruction |
| 62 ; CHECK: movzx |
| 63 ; CHECK: and {{.*}}, 1 |
| 64 |
| 65 ; Test zext to i32. |
| 66 define internal i32 @testZextI32(i32 %arg) { |
| 67 entry: |
| 68 %arg_i1 = trunc i32 %arg to i1 |
| 69 %result_i32 = zext i1 %arg_i1 to i32 |
| 70 ret i32 %result_i32 |
| 71 } |
| 72 ; CHECK-LABEL: testZextI32 |
| 73 ; match the trunc instruction |
| 74 ; CHECK: and {{.*}}, 1 |
| 75 ; match the zext i1 instruction |
| 76 ; CHECK: movzx |
| 77 ; CHECK: and {{.*}}, 1 |
| 78 |
| 79 ; Test zext to i64. |
| 80 define internal i64 @testZextI64(i32 %arg) { |
| 81 entry: |
| 82 %arg_i1 = trunc i32 %arg to i1 |
| 83 %result_i64 = zext i1 %arg_i1 to i64 |
| 84 ret i64 %result_i64 |
| 85 } |
| 86 ; CHECK-LABEL: testZextI64 |
| 87 ; match the trunc instruction |
| 88 ; CHECK: and {{.*}}, 1 |
| 89 ; match the zext i1 instruction |
| 90 ; CHECK: movzx |
| 91 ; CHECK: and {{.*}}, 1 |
| 92 ; CHECK: mov {{.*}}, 0 |
| 93 |
| 94 ; Test sext to i8. |
| 95 define internal i32 @testSextI8(i32 %arg) { |
| 96 entry: |
| 97 %arg_i1 = trunc i32 %arg to i1 |
| 98 %result_i8 = sext i1 %arg_i1 to i8 |
| 99 %result = sext i8 %result_i8 to i32 |
| 100 ret i32 %result |
| 101 } |
| 102 ; CHECK-LABEL: testSextI8 |
| 103 ; match the trunc instruction |
| 104 ; CHECK: and {{.*}}, 1 |
| 105 ; match the sext i1 instruction |
| 106 ; CHECK: shl [[REG:.*]], 7 |
| 107 ; CHECK-NEXT: sar [[REG]], 7 |
| 108 |
| 109 ; Test sext to i16. |
| 110 define internal i32 @testSextI16(i32 %arg) { |
| 111 entry: |
| 112 %arg_i1 = trunc i32 %arg to i1 |
| 113 %result_i16 = sext i1 %arg_i1 to i16 |
| 114 %result = sext i16 %result_i16 to i32 |
| 115 ret i32 %result |
| 116 } |
| 117 ; CHECK-LABEL: testSextI16 |
| 118 ; match the trunc instruction |
| 119 ; CHECK: and {{.*}}, 1 |
| 120 ; match the sext i1 instruction |
| 121 ; CHECK: movzx [[REG:.*]], |
| 122 ; CHECK-NEXT: shl [[REG]], 15 |
| 123 ; CHECK-NEXT: sar [[REG]], 15 |
| 124 |
| 125 ; Test sext to i32. |
| 126 define internal i32 @testSextI32(i32 %arg) { |
| 127 entry: |
| 128 %arg_i1 = trunc i32 %arg to i1 |
| 129 %result_i32 = sext i1 %arg_i1 to i32 |
| 130 ret i32 %result_i32 |
| 131 } |
| 132 ; CHECK-LABEL: testSextI32 |
| 133 ; match the trunc instruction |
| 134 ; CHECK: and {{.*}}, 1 |
| 135 ; match the sext i1 instruction |
| 136 ; CHECK: movzx [[REG:.*]], |
| 137 ; CHECK-NEXT: shl [[REG]], 31 |
| 138 ; CHECK-NEXT: sar [[REG]], 31 |
| 139 |
| 140 ; Test sext to i64. |
| 141 define internal i64 @testSextI64(i32 %arg) { |
| 142 entry: |
| 143 %arg_i1 = trunc i32 %arg to i1 |
| 144 %result_i64 = sext i1 %arg_i1 to i64 |
| 145 ret i64 %result_i64 |
| 146 } |
| 147 ; CHECK-LABEL: testSextI64 |
| 148 ; match the trunc instruction |
| 149 ; CHECK: and {{.*}}, 1 |
| 150 ; match the sext i1 instruction |
| 151 ; CHECK: movzx [[REG:.*]], |
| 152 ; CHECK-NEXT: shl [[REG]], 31 |
| 153 ; CHECK-NEXT: sar [[REG]], 31 |
| 154 |
| 155 ; Test fptosi float to i1. |
| 156 define internal i32 @testFptosiFloat(float %arg) { |
| 157 entry: |
| 158 %arg_i1 = fptosi float %arg to i1 |
| 159 %result = sext i1 %arg_i1 to i32 |
| 160 ret i32 %result |
| 161 } |
| 162 ; CHECK-LABEL: testFptosiFloat |
| 163 ; CHECK: cvttss2si |
| 164 ; CHECK: and {{.*}}, 1 |
| 165 ; CHECK: movzx [[REG:.*]], |
| 166 ; CHECK-NEXT: shl [[REG]], 31 |
| 167 ; CHECK-NEXT: sar [[REG]], 31 |
| 168 |
| 169 ; Test fptosi double to i1. |
| 170 define internal i32 @testFptosiDouble(double %arg) { |
| 171 entry: |
| 172 %arg_i1 = fptosi double %arg to i1 |
| 173 %result = sext i1 %arg_i1 to i32 |
| 174 ret i32 %result |
| 175 } |
| 176 ; CHECK-LABEL: testFptosiDouble |
| 177 ; CHECK: cvttsd2si |
| 178 ; CHECK: and {{.*}}, 1 |
| 179 ; CHECK: movzx [[REG:.*]], |
| 180 ; CHECK-NEXT: shl [[REG]], 31 |
| 181 ; CHECK-NEXT: sar [[REG]], 31 |
| 182 |
| 183 ; ERRORS-NOT: ICE translation error |
| 184 ; DUMP-NOT: SZ |
OLD | NEW |