@@ -601,7 +601,7 @@ Gallery
601
601
=======
602
602
603
603
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.
605
605
606
606
.. code-block :: text
607
607
:caption: Example fold zext(trunc:nuw)
@@ -630,3 +630,20 @@ using wip_match_opcode in patterns.
630
630
(G_ZEXT $root, $src),
631
631
[{ return Helper.matchZextOfTrunc(${root}, ${matchinfo}); }]),
632
632
(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