1
1
// RUN: llvm-tblgen -I %p/../../../include -gen-global-isel-combiner \
2
- // RUN: -gicombiner-debug-typeinfer -combiners=MyCombiner %s 2>&1 | \
2
+ // RUN: -gicombiner-debug-typeinfer -combiners=MyCombiner %s 2>&1 >/dev/null | \
3
3
// RUN: FileCheck %s
4
4
5
5
// Checks reasoning of the inference rules.
@@ -10,13 +10,15 @@ include "llvm/Target/GlobalISel/Combine.td"
10
10
def MyTargetISA : InstrInfo;
11
11
def MyTarget : Target { let InstructionSet = MyTargetISA; }
12
12
13
+ // This also checks that the type of a def is preferred when inferring the type
14
+ // of an immediate.
13
15
// CHECK: Rule Operand Type Equivalence Classes for inference_mul_by_neg_one:
14
16
// CHECK-NEXT: Groups for __inference_mul_by_neg_one_match_0: [dst, x]
15
17
// CHECK-NEXT: Groups for __inference_mul_by_neg_one_apply_0: [dst, x]
16
18
// CHECK-NEXT: Final Type Equivalence Classes: [dst, x]
17
- // CHECK-NEXT: INFER: imm 0 -> GITypeOf<$x >
19
+ // CHECK-NEXT: INFER: imm 0 -> GITypeOf<$dst >
18
20
// 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])
21
+ // CHECK-NEXT: (CodeGenInstructionPattern name:__inference_mul_by_neg_one_apply_0 G_SUB operands:[<def>$dst, (GITypeOf<$dst > 0), $x])
20
22
def inference_mul_by_neg_one: GICombineRule <
21
23
(defs root:$dst),
22
24
(match (G_MUL $dst, $x, -1)),
@@ -61,8 +63,25 @@ def infer_variadic_outs: GICombineRule <
61
63
(COPY $dst, $tmp))
62
64
>;
63
65
66
+ // Check that the type of an immediate is inferred when there is just one
67
+ // element in the corresponding equivalence class.
68
+ // CHECK: Rule Operand Type Equivalence Classes for infer_imm_0:
69
+ // CHECK-NEXT: Groups for __infer_imm_0_match_0: [dst]
70
+ // CHECK-NEXT: Groups for __infer_imm_0_apply_0: [dst]
71
+ // CHECK-NEXT: Final Type Equivalence Classes: [dst]
72
+ // CHECK-NEXT: INFER: imm 1 -> GITypeOf<$dst>
73
+ // CHECK-NEXT: INFER: imm 2 -> GITypeOf<$dst>
74
+ // CHECK-NEXT: Apply patterns for rule infer_imm_0 after inference:
75
+ // CHECK-NEXT: (CodeGenInstructionPattern name:__infer_imm_0_apply_0 G_ADD operands:[<def>$dst, (GITypeOf<$dst> 1), (GITypeOf<$dst> 2)])
76
+ def infer_imm_0 : GICombineRule<
77
+ (defs root:$dst),
78
+ (match (G_ADD $dst, 0, 3)),
79
+ (apply (G_ADD $dst, 1, 2))
80
+ >;
81
+
64
82
def MyCombiner: GICombiner<"GenMyCombiner", [
65
83
inference_mul_by_neg_one,
66
84
infer_complex_tempreg,
67
- infer_variadic_outs
85
+ infer_variadic_outs,
86
+ infer_imm_0,
68
87
]>;
0 commit comments