| OLD | NEW |
| 1 ; Simple test of the select instruction. The CHECK lines are only | 1 ; Simple test of the select instruction. The CHECK lines are only |
| 2 ; checking for basic instruction patterns that should be present | 2 ; checking for basic instruction patterns that should be present |
| 3 ; regardless of the optimization level, so there are no special OPTM1 | 3 ; regardless of the optimization level, so there are no special OPTM1 |
| 4 ; match lines. | 4 ; match lines. |
| 5 | 5 |
| 6 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -O2 | FileCheck %s | 6 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -O2 | FileCheck %s |
| 7 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -Om1 | FileCheck %s | 7 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -Om1 | FileCheck %s |
| 8 | 8 |
| 9 define void @testSelect(i32 %a, i32 %b) { | 9 define void @testSelect(i32 %a, i32 %b) { |
| 10 entry: | 10 entry: |
| 11 %cmp = icmp slt i32 %a, %b | 11 %cmp = icmp slt i32 %a, %b |
| 12 %cond = select i1 %cmp, i32 %a, i32 %b | 12 %cond = select i1 %cmp, i32 %a, i32 %b |
| 13 tail call void @useInt(i32 %cond) | 13 tail call void @useInt(i32 %cond) |
| 14 %cmp1 = icmp sgt i32 %a, %b | 14 %cmp1 = icmp sgt i32 %a, %b |
| 15 %cond2 = select i1 %cmp1, i32 10, i32 20 | 15 %cond2 = select i1 %cmp1, i32 10, i32 20 |
| 16 tail call void @useInt(i32 %cond2) | 16 tail call void @useInt(i32 %cond2) |
| 17 ; Create "fake" uses of %cmp and %cmp1 to prevent O2 bool folding. |
| 18 %d1 = zext i1 %cmp to i32 |
| 19 call void @useInt(i32 %d1) |
| 20 %d2 = zext i1 %cmp1 to i32 |
| 21 call void @useInt(i32 %d2) |
| 17 ret void | 22 ret void |
| 18 } | 23 } |
| 19 | 24 |
| 20 declare void @useInt(i32 %x) | 25 declare void @useInt(i32 %x) |
| 21 | 26 |
| 22 ; CHECK-LABEL: testSelect | 27 ; CHECK-LABEL: testSelect |
| 23 ; CHECK: cmp | 28 ; CHECK: cmp |
| 24 ; CHECK: cmp | 29 ; CHECK: cmp |
| 25 ; CHECK: call {{.*}} R_{{.*}} useInt | 30 ; CHECK: call {{.*}} R_{{.*}} useInt |
| 26 ; CHECK: cmp | 31 ; CHECK: cmp |
| (...skipping 14 matching lines...) Expand all Loading... |
| 41 ; Check for valid addressing mode in the cmp instruction when the | 46 ; Check for valid addressing mode in the cmp instruction when the |
| 42 ; operand is an immediate. There is a different x86-32 lowering | 47 ; operand is an immediate. There is a different x86-32 lowering |
| 43 ; sequence for 64-bit operands. | 48 ; sequence for 64-bit operands. |
| 44 define i64 @testSelectImm64(i64 %a, i64 %b) { | 49 define i64 @testSelectImm64(i64 %a, i64 %b) { |
| 45 entry: | 50 entry: |
| 46 %cond = select i1 true, i64 %a, i64 %b | 51 %cond = select i1 true, i64 %a, i64 %b |
| 47 ret i64 %cond | 52 ret i64 %cond |
| 48 } | 53 } |
| 49 ; CHECK-LABEL: testSelectImm64 | 54 ; CHECK-LABEL: testSelectImm64 |
| 50 ; CHECK-NOT: cmp 0x{{[0-9a-f]+}}, | 55 ; CHECK-NOT: cmp 0x{{[0-9a-f]+}}, |
| OLD | NEW |