Skip to content

GlobalISel: Unable to use intrinsics in matcher patterns #62628

@arsenm

Description

@arsenm

There appears to be no way to make use of intrinsics in matcher patterns. If I try an ugly way of referring to G_INTRINSIC, it just crashes:

def expand_promoted_fmed3 : GICombineRule<
  (defs root:$fptrunc_dst, expand_promoted_fmed3_matchdata:$matchinfo),
  (match (G_FPTRUNC $fptrunc_dst, $fmed3_dst):$fptrunc,
  (G_INTRINSIC int_amdgcn_fmed3, $fmed3_dst, $src0, $src1, $src2),
    [{ return Helper.matchExpandPromotedF16FMed3(*${fptrunc}, ${src0}.getReg(), ${src1}.getReg(), ${src2}.getReg()); }]),
  (apply [{ Helper.applyExpandPromotedF16FMed3(*${fptrunc}, ${src0}.getReg(), ${src1}.getReg(), ${src2}.getReg()); }])
>;

I would expect to not require the G_INTRINSIC part, which hits an error:

/Users/matt/src/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUCombine.td:134:5: error: Expected a subclass of GIMatchKind or a sub-dag whose operator is either of a GIMatchKindWithArgs or Instruction
def expand_promoted_fmed3 : GICombineRule<
    ^
note: Pattern was `(int_amdgcn_fmed3 ?:$fmed3_dst, ?:$src0, ?:$src1, ?:$src2)'
Included from /Users/matt/src/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUGISel.td:14:
/Users/matt/src/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUCombine.td:134:5: error: Failed to parse rule
def expand_promoted_fmed3 : GICombineRule<
    ^
Included from /Users/matt/src/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUGISel.td:14:
/Users/matt/src/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUCombine.td:156:5: error: Failed to parse one or more rules
def AMDGPUPostLegalizerCombinerHelper: GICombinerHelper<

The diagnostic is also quite poor since it's not pointing at the specific problematic token, and only at the top level rule

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions