Skip to content

Commit bece0d7

Browse files
author
Thorsten Schütt
authored
[GlobalIsel] Update MIR gallery (#107903)
add more patterns clarify wip_match_opcode usage
1 parent 06c3311 commit bece0d7

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

llvm/docs/GlobalISel/MIRPatterns.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ Gallery
601601
=======
602602

603603
We should use precise patterns that state our intentions. Please avoid
604-
using wip_match_opcode in patterns.
604+
using wip_match_opcode in patterns. It can lead to imprecise patterns.
605605

606606
.. code-block:: text
607607
:caption: Example fold zext(trunc:nuw)
@@ -630,3 +630,20 @@ using wip_match_opcode in patterns.
630630
(G_ZEXT $root, $src),
631631
[{ return Helper.matchZextOfTrunc(${root}, ${matchinfo}); }]),
632632
(apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
633+
634+
635+
// Precise: lists all combine combinations
636+
class ext_of_ext_opcodes<Instruction ext1Opcode, Instruction ext2Opcode> : GICombineRule <
637+
(defs root:$root, build_fn_matchinfo:$matchinfo),
638+
(match (ext2Opcode $second, $src):$Second,
639+
(ext1Opcode $root, $second):$First,
640+
[{ return Helper.matchExtOfExt(*${First}, *${Second}, ${matchinfo}); }]),
641+
(apply [{ Helper.applyBuildFn(*${First}, ${matchinfo}); }])>;
642+
643+
def zext_of_zext : ext_of_ext_opcodes<G_ZEXT, G_ZEXT>;
644+
def zext_of_anyext : ext_of_ext_opcodes<G_ZEXT, G_ANYEXT>;
645+
def sext_of_sext : ext_of_ext_opcodes<G_SEXT, G_SEXT>;
646+
def sext_of_anyext : ext_of_ext_opcodes<G_SEXT, G_ANYEXT>;
647+
def anyext_of_anyext : ext_of_ext_opcodes<G_ANYEXT, G_ANYEXT>;
648+
def anyext_of_zext : ext_of_ext_opcodes<G_ANYEXT, G_ZEXT>;
649+
def anyext_of_sext : ext_of_ext_opcodes<G_ANYEXT, G_SEXT>;

0 commit comments

Comments
 (0)