| 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: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ |
| 7 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -Om1 | FileCheck %s | 7 ; RUN: --target x8632 -i %s --args -O2 \ |
| 8 ; RUN: | %if --need=target_X8632 --command FileCheck %s |
| 9 ; RUN: %if --need=target_X8632 --command %p2i --filetype=obj --disassemble \ |
| 10 ; RUN: --target x8632 -i %s --args -Om1 \ |
| 11 ; RUN: | %if --need=target_X8632 --command FileCheck %s |
| 12 |
| 13 ; RUN: %if --need=target_ARM32 --need=allow_dump \ |
| 14 ; RUN: --command %p2i --filetype=asm --assemble \ |
| 15 ; RUN: --disassemble --target arm32 -i %s --args -O2 --skip-unimplemented \ |
| 16 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ |
| 17 ; RUN: --command FileCheck --check-prefix ARM32 %s |
| 18 ; RUN: %if --need=target_ARM32 --need=allow_dump \ |
| 19 ; RUN: --command %p2i --filetype=asm --assemble \ |
| 20 ; RUN: --disassemble --target arm32 -i %s --args -Om1 --skip-unimplemented \ |
| 21 ; RUN: | %if --need=target_ARM32 --need=allow_dump \ |
| 22 ; RUN: --command FileCheck --check-prefix ARM32 %s |
| 8 | 23 |
| 9 define void @testSelect(i32 %a, i32 %b) { | 24 define void @testSelect(i32 %a, i32 %b) { |
| 10 entry: | 25 entry: |
| 11 %cmp = icmp slt i32 %a, %b | 26 %cmp = icmp slt i32 %a, %b |
| 12 %cond = select i1 %cmp, i32 %a, i32 %b | 27 %cond = select i1 %cmp, i32 %a, i32 %b |
| 13 tail call void @useInt(i32 %cond) | 28 tail call void @useInt(i32 %cond) |
| 14 %cmp1 = icmp sgt i32 %a, %b | 29 %cmp1 = icmp sgt i32 %a, %b |
| 15 %cond2 = select i1 %cmp1, i32 10, i32 20 | 30 %cond2 = select i1 %cmp1, i32 10, i32 20 |
| 16 tail call void @useInt(i32 %cond2) | 31 tail call void @useInt(i32 %cond2) |
| 17 ; Create "fake" uses of %cmp and %cmp1 to prevent O2 bool folding. | 32 ; Create "fake" uses of %cmp and %cmp1 to prevent O2 bool folding. |
| 18 %d1 = zext i1 %cmp to i32 | 33 %d1 = zext i1 %cmp to i32 |
| 19 call void @useInt(i32 %d1) | 34 call void @useInt(i32 %d1) |
| 20 %d2 = zext i1 %cmp1 to i32 | 35 %d2 = zext i1 %cmp1 to i32 |
| 21 call void @useInt(i32 %d2) | 36 call void @useInt(i32 %d2) |
| 22 ret void | 37 ret void |
| 23 } | 38 } |
| 24 | 39 |
| 25 declare void @useInt(i32 %x) | 40 declare void @useInt(i32 %x) |
| 26 | 41 |
| 27 ; CHECK-LABEL: testSelect | 42 ; CHECK-LABEL: testSelect |
| 28 ; CHECK: cmp | 43 ; CHECK: cmp |
| 29 ; CHECK: cmp | 44 ; CHECK: cmp |
| 30 ; CHECK: call {{.*}} R_{{.*}} useInt | 45 ; CHECK: call {{.*}} R_{{.*}} useInt |
| 31 ; CHECK: cmp | 46 ; CHECK: cmp |
| 32 ; CHECK: cmp | 47 ; CHECK: cmp |
| 33 ; CHECK: call {{.*}} R_{{.*}} useInt | 48 ; CHECK: call {{.*}} R_{{.*}} useInt |
| 34 ; CHECK: ret | 49 ; CHECK: ret |
| 50 ; ARM32-LABEL: testSelect |
| 51 ; ARM32: cmp |
| 52 ; ARM32: cmp |
| 53 ; ARM32: bl {{.*}} useInt |
| 54 ; ARM32: cmp |
| 55 ; ARM32: cmp |
| 56 ; ARM32: mov {{.*}}, #20 |
| 57 ; ARM32: movne {{.*}}, #10 |
| 58 ; ARM32: bl {{.*}} useInt |
| 59 ; ARM32: bx lr |
| 35 | 60 |
| 36 ; Check for valid addressing mode in the cmp instruction when the | 61 ; Check for valid addressing mode in the cmp instruction when the |
| 37 ; operand is an immediate. | 62 ; operand is an immediate. |
| 38 define i32 @testSelectImm32(i32 %a, i32 %b) { | 63 define i32 @testSelectImm32(i32 %a, i32 %b) { |
| 39 entry: | 64 entry: |
| 40 %cond = select i1 false, i32 %a, i32 %b | 65 %cond = select i1 false, i32 %a, i32 %b |
| 41 ret i32 %cond | 66 ret i32 %cond |
| 42 } | 67 } |
| 43 ; CHECK-LABEL: testSelectImm32 | 68 ; CHECK-LABEL: testSelectImm32 |
| 44 ; CHECK-NOT: cmp 0x{{[0-9a-f]+}}, | 69 ; CHECK-NOT: cmp 0x{{[0-9a-f]+}}, |
| 70 ; ARM32-LABEL: testSelectImm32 |
| 71 ; ARM32-NOT: cmp #{{.*}}, |
| 45 | 72 |
| 46 ; Check for valid addressing mode in the cmp instruction when the | 73 ; Check for valid addressing mode in the cmp instruction when the |
| 47 ; operand is an immediate. There is a different x86-32 lowering | 74 ; operand is an immediate. There is a different x86-32 lowering |
| 48 ; sequence for 64-bit operands. | 75 ; sequence for 64-bit operands. |
| 49 define i64 @testSelectImm64(i64 %a, i64 %b) { | 76 define i64 @testSelectImm64(i64 %a, i64 %b) { |
| 50 entry: | 77 entry: |
| 51 %cond = select i1 true, i64 %a, i64 %b | 78 %cond = select i1 true, i64 %a, i64 %b |
| 52 ret i64 %cond | 79 ret i64 %cond |
| 53 } | 80 } |
| 54 ; CHECK-LABEL: testSelectImm64 | 81 ; CHECK-LABEL: testSelectImm64 |
| 55 ; CHECK-NOT: cmp 0x{{[0-9a-f]+}}, | 82 ; CHECK-NOT: cmp 0x{{[0-9a-f]+}}, |
| 83 ; ARM32-LABEL: testSelectImm64 |
| 84 ; ARM32-NOT: cmp #{{.*}}, |
| OLD | NEW |