|
1 | 1 | ; This test aims to check ability to support "Arithmetic with Overflow" intrinsics
|
2 | 2 | ; in the special case when those intrinsics are being generated by the CodeGenPrepare;
|
3 |
| -; pass during translations with optimization (note -O3 in llc arguments). |
| 3 | +; pass during translations with optimization (note -disable-lsr, to inhibit |
| 4 | +; strength reduction pre-empting with a more preferable match for this pattern |
| 5 | +; in llc arguments). |
4 | 6 |
|
5 | 7 | ; RUN: llc -O3 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
|
6 | 8 | ; RUN: %if spirv-tools %{ llc -O3 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
|
7 | 9 |
|
8 | 10 | ; RUN: llc -O3 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
|
9 | 11 | ; RUN: %if spirv-tools %{ llc -O3 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
|
10 | 12 |
|
11 |
| -; CHECK-DAG: OpName %[[Val:.*]] "math" |
12 |
| -; CHECK-DAG: OpName %[[IsOver:.*]] "ov" |
| 13 | +; RUN: llc -O3 -disable-lsr -mtriple=spirv32-unknown-unknown %s -o - | FileCheck --check-prefix=NOLSR %s |
| 14 | +; RUN: %if spirv-tools %{ llc -O3 -disable-lsr -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 15 | + |
| 16 | +; RUN: llc -O3 -disable-lsr -mtriple=spirv64-unknown-unknown %s -o - | FileCheck --check-prefix=NOLSR %s |
| 17 | +; RUN: %if spirv-tools %{ llc -O3 -disable-lsr -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 18 | + |
| 19 | +; CHECK-DAG: OpName %[[PhiRes:.*]] "lsr.iv" |
| 20 | +; CHECK-DAG: OpName %[[IsOver:.*]] "fl" |
| 21 | +; CHECK-DAG: OpName %[[Val:.*]] "lsr.iv.next" |
13 | 22 | ; CHECK-DAG: %[[Int:.*]] = OpTypeInt 32 0
|
14 | 23 | ; CHECK-DAG: %[[Char:.*]] = OpTypeInt 8 0
|
15 | 24 | ; CHECK-DAG: %[[PtrChar:.*]] = OpTypePointer Generic %[[Char]]
|
16 | 25 | ; CHECK-DAG: %[[Bool:.*]] = OpTypeBool
|
17 |
| -; CHECK-DAG: %[[Struct:.*]] = OpTypeStruct %[[Int]] %[[Int]] |
18 | 26 | ; CHECK-DAG: %[[Const1:.*]] = OpConstant %[[Int]] 1
|
| 27 | +; CHECK-DAG: %[[Zero:.*]] = OpConstant %[[Int]] 0 |
19 | 28 | ; CHECK-DAG: %[[Const42:.*]] = OpConstant %[[Char]] 42
|
20 |
| -; CHECK-DAG: %[[Zero:.*]] = OpConstantNull %[[Int]] |
21 | 29 |
|
22 | 30 | ; CHECK: OpFunction
|
23 | 31 | ; CHECK: %[[A:.*]] = OpFunctionParameter %[[Int]]
|
24 | 32 | ; CHECK: %[[Ptr:.*]] = OpFunctionParameter %[[PtrChar]]
|
25 |
| -; CHECK: %[[#]] = OpLabel |
26 |
| -; CHECK: OpBranch %[[#]] |
27 |
| -; CHECK: %[[#]] = OpLabel |
28 |
| -; CHECK: %[[PhiRes:.*]] = OpPhi %[[Int]] %[[A]] %[[#]] %[[Val]] %[[#]] |
29 |
| -; CHECK: %[[AggRes:.*]] = OpIAddCarry %[[Struct]] %[[PhiRes]] %[[Const1]] |
30 |
| -; CHECK: %[[Val]] = OpCompositeExtract %[[Int]] %[[AggRes]] 0 |
31 |
| -; CHECK: %[[Over:.*]] = OpCompositeExtract %[[Int]] %[[AggRes]] 1 |
32 |
| -; CHECK: %[[IsOver]] = OpINotEqual %[[Bool:.*]] %[[Over]] %[[Zero]] |
33 |
| -; CHECK: OpBranchConditional %[[IsOver]] %[[#]] %[[#]] |
34 |
| -; CHECK: OpStore %[[Ptr]] %[[Const42]] Aligned 1 |
| 33 | +; CHECK: %[[APlusOne:.*]] = OpIAdd %[[Int]] %[[A]] %[[Const1]] |
| 34 | +; CHECK: OpBranch %[[#]] |
| 35 | +; CHECK: [[#]] = OpLabel |
| 36 | +; CHECK: %[[PhiRes]] = OpPhi %[[Int]] %[[Val]] %[[#]] %[[APlusOne]] %[[#]] |
| 37 | +; CHECK: %[[IsOver]] = OpIEqual %[[Bool]] %[[#]] %[[#]] |
| 38 | +; CHECK: OpBranchConditional %[[IsOver]] %[[#]] %[[#]] |
| 39 | +; CHECK: [[#]] = OpLabel |
| 40 | +; CHECK: OpStore %[[Ptr]] %[[Const42]] Aligned 1 |
| 41 | +; CHECK: [[Val]] = OpIAdd %[[Int]] %[[PhiRes]] %[[Const1]] |
35 | 42 | ; CHECK: OpBranch %[[#]]
|
36 |
| -; CHECK: %[[#]] = OpLabel |
37 |
| -; CHECK: OpReturnValue %[[Val]] |
38 |
| -; CHECK: OpFunctionEnd |
| 43 | +; CHECK: [[#]] = OpLabel |
| 44 | +; OpReturnValue %[[PhiRes]] |
| 45 | + |
| 46 | +; NOLSR-DAG: OpName %[[Val:.*]] "math" |
| 47 | +; NOLSR-DAG: OpName %[[IsOver:.*]] "ov" |
| 48 | +; NOLSR-DAG: %[[Int:.*]] = OpTypeInt 32 0 |
| 49 | +; NOLSR-DAG: %[[Char:.*]] = OpTypeInt 8 0 |
| 50 | +; NOLSR-DAG: %[[PtrChar:.*]] = OpTypePointer Generic %[[Char]] |
| 51 | +; NOLSR-DAG: %[[Bool:.*]] = OpTypeBool |
| 52 | +; NOLSR-DAG: %[[Struct:.*]] = OpTypeStruct %[[Int]] %[[Int]] |
| 53 | +; NOLSR-DAG: %[[Const1:.*]] = OpConstant %[[Int]] 1 |
| 54 | +; NOLSR-DAG: %[[Const42:.*]] = OpConstant %[[Char]] 42 |
| 55 | +; NOLSR-DAG: %[[Zero:.*]] = OpConstantNull %[[Int]] |
| 56 | + |
| 57 | +; NOLSR: OpFunction |
| 58 | +; NOLSR: %[[A:.*]] = OpFunctionParameter %[[Int]] |
| 59 | +; NOLSR: %[[Ptr:.*]] = OpFunctionParameter %[[PtrChar]] |
| 60 | +; NOLSR: %[[#]] = OpLabel |
| 61 | +; NOLSR: OpBranch %[[#]] |
| 62 | +; NOLSR: %[[#]] = OpLabel |
| 63 | +; NOLSR: %[[PhiRes:.*]] = OpPhi %[[Int]] %[[A]] %[[#]] %[[Val]] %[[#]] |
| 64 | +; NOLSR: %[[AggRes:.*]] = OpIAddCarry %[[Struct]] %[[PhiRes]] %[[Const1]] |
| 65 | +; NOLSR: %[[Val]] = OpCompositeExtract %[[Int]] %[[AggRes]] 0 |
| 66 | +; NOLSR: %[[Over:.*]] = OpCompositeExtract %[[Int]] %[[AggRes]] 1 |
| 67 | +; NOLSR: %[[IsOver]] = OpINotEqual %[[Bool:.*]] %[[Over]] %[[Zero]] |
| 68 | +; NOLSR: OpBranchConditional %[[IsOver]] %[[#]] %[[#]] |
| 69 | +; NOLSR: OpStore %[[Ptr]] %[[Const42]] Aligned 1 |
| 70 | +; NOLSR: OpBranch %[[#]] |
| 71 | +; NOLSR: %[[#]] = OpLabel |
| 72 | +; NOLSR: OpReturnValue %[[Val]] |
| 73 | +; NOLSR: OpFunctionEnd |
39 | 74 |
|
40 | 75 | define spir_func i32 @foo(i32 %a, ptr addrspace(4) %p) {
|
41 | 76 | entry:
|
|
0 commit comments