|
| 1 | +// RUN: llvm-tblgen -I %p/../../../include -gen-global-isel-combiner \ |
| 2 | +// RUN: -gicombiner-debug-typeinfer -combiners=MyCombiner %s 2>&1 | \ |
| 3 | +// RUN: FileCheck %s |
| 4 | + |
| 5 | +// Checks reasoning of the inference rules. |
| 6 | + |
| 7 | +include "llvm/Target/Target.td" |
| 8 | +include "llvm/Target/GlobalISel/Combine.td" |
| 9 | + |
| 10 | +def MyTargetISA : InstrInfo; |
| 11 | +def MyTarget : Target { let InstructionSet = MyTargetISA; } |
| 12 | + |
| 13 | +// CHECK: Rule Operand Type Equivalence Classes for inference_mul_by_neg_one: |
| 14 | +// CHECK-NEXT: Groups for __inference_mul_by_neg_one_match_0: [dst, x] |
| 15 | +// CHECK-NEXT: Groups for __inference_mul_by_neg_one_apply_0: [dst, x] |
| 16 | +// CHECK-NEXT: Final Type Equivalence Classes: [dst, x] |
| 17 | +// CHECK-NEXT: INFER: imm 0 -> GITypeOf<$x> |
| 18 | +// CHECK-NEXT: Apply patterns for rule inference_mul_by_neg_one after inference: |
| 19 | +// CHECK-NEXT: (CodeGenInstructionPattern name:__inference_mul_by_neg_one_apply_0 G_SUB operands:[<def>$dst, (GITypeOf<$x> 0), $x]) |
| 20 | +def inference_mul_by_neg_one: GICombineRule < |
| 21 | + (defs root:$dst), |
| 22 | + (match (G_MUL $dst, $x, -1)), |
| 23 | + (apply (G_SUB $dst, 0, $x)) |
| 24 | +>; |
| 25 | + |
| 26 | +// CHECK: Rule Operand Type Equivalence Classes for infer_complex_tempreg: |
| 27 | +// CHECK-NEXT: Groups for __infer_complex_tempreg_match_0: [dst] [x, y, z] |
| 28 | +// CHECK-NEXT: Groups for __infer_complex_tempreg_apply_0: [tmp2] [x, y] |
| 29 | +// CHECK-NEXT: Groups for __infer_complex_tempreg_apply_1: [tmp, tmp2] |
| 30 | +// CHECK-NEXT: Groups for __infer_complex_tempreg_apply_2: [dst, tmp] |
| 31 | +// CHECK-NEXT: Final Type Equivalence Classes: [dst, tmp, tmp2] [x, y, z] |
| 32 | +// CHECK-NEXT: INFER: MachineOperand $tmp2 -> GITypeOf<$dst> |
| 33 | +// CHECK-NEXT: INFER: MachineOperand $tmp -> GITypeOf<$dst> |
| 34 | +// CHECK-NEXT: Apply patterns for rule infer_complex_tempreg after inference: |
| 35 | +// CHECK-NEXT: (CodeGenInstructionPattern name:__infer_complex_tempreg_apply_0 G_BUILD_VECTOR operands:[<def>GITypeOf<$dst>:$tmp2, $x, $y]) |
| 36 | +// CHECK-NEXT: (CodeGenInstructionPattern name:__infer_complex_tempreg_apply_1 G_FNEG operands:[<def>GITypeOf<$dst>:$tmp, GITypeOf<$dst>:$tmp2]) |
| 37 | +// CHECK-NEXT: (CodeGenInstructionPattern name:__infer_complex_tempreg_apply_2 G_FNEG operands:[<def>$dst, GITypeOf<$dst>:$tmp]) |
| 38 | +def infer_complex_tempreg: GICombineRule < |
| 39 | + (defs root:$dst), |
| 40 | + (match (G_MERGE_VALUES $dst, $x, $y, $z)), |
| 41 | + (apply (G_BUILD_VECTOR $tmp2, $x, $y), |
| 42 | + (G_FNEG $tmp, $tmp2), |
| 43 | + (G_FNEG $dst, $tmp)) |
| 44 | +>; |
| 45 | + |
| 46 | +// CHECK: Rule Operand Type Equivalence Classes for infer_variadic_outs: |
| 47 | +// CHECK-NEXT: Groups for __infer_variadic_outs_match_0: [x, y] [vec] |
| 48 | +// CHECK-NEXT: Groups for __infer_variadic_outs_match_1: [dst, x] |
| 49 | +// CHECK-NEXT: Groups for __infer_variadic_outs_apply_0: [tmp, y] |
| 50 | +// CHECK-NEXT: Groups for __infer_variadic_outs_apply_1: |
| 51 | +// CHECK-NEXT: Final Type Equivalence Classes: [tmp, dst, x, y] [vec] |
| 52 | +// CHECK-NEXT: INFER: MachineOperand $tmp -> GITypeOf<$dst> |
| 53 | +// CHECK-NEXT: Apply patterns for rule infer_variadic_outs after inference: |
| 54 | +// CHECK-NEXT: (CodeGenInstructionPattern name:__infer_variadic_outs_apply_0 G_FNEG operands:[<def>GITypeOf<$dst>:$tmp, $y]) |
| 55 | +// CHECK-NEXT: (CodeGenInstructionPattern name:__infer_variadic_outs_apply_1 COPY operands:[<def>$dst, GITypeOf<$dst>:$tmp]) |
| 56 | +def infer_variadic_outs: GICombineRule < |
| 57 | + (defs root:$dst), |
| 58 | + (match (G_UNMERGE_VALUES $x, $y, $vec), |
| 59 | + (G_FNEG $dst, $x)), |
| 60 | + (apply (G_FNEG $tmp, $y), |
| 61 | + (COPY $dst, $tmp)) |
| 62 | +>; |
| 63 | + |
| 64 | +def MyCombiner: GICombiner<"GenMyCombiner", [ |
| 65 | + inference_mul_by_neg_one, |
| 66 | + infer_complex_tempreg, |
| 67 | + infer_variadic_outs |
| 68 | +]>; |
0 commit comments