[llvm] [GlobalIsel] Add Gallery to MIR Patterns (PR #89974)

Thorsten Schütt via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 25 02:35:17 PDT 2024


================
@@ -514,3 +514,29 @@ of operands.
     (match (does_not_bind $tmp, $x)
            (G_MUL $dst, $x, $tmp)),
     (apply (COPY $dst, $x))>;
+
+
+ Gallery
+----------------
+
+We should use precise patterns that state our intentions. Please avoid
+using wip_match_opcode in patterns.
+
+.. code-block:: text
+  :caption: Example fold ext(trunc:nuw)
+
+(match (wip_match_opcode G_ZEXT):$root,
+   [{ return Helper.matchZextOfTrunc(${root}, ${matchinfo}); }]),
+   (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
+
+
+(match (G_TRUNC $src, $x),
----------------
tschuett wrote:

At the top it states: fold ext(trunk:nuw)
I want to prevent misbehaviour like:
https://github.com/llvm/llvm-project/blob/fc538b070de69315fe05105e8c0bc622fb61168a/llvm/include/llvm/Target/GlobalISel/Combine.td#L722

https://github.com/llvm/llvm-project/pull/89974


More information about the llvm-commits mailing list