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

via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 24 11:49:07 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-globalisel

Author: Thorsten Schütt (tschuett)

<details>
<summary>Changes</summary>



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


1 Files Affected:

- (modified) llvm/docs/GlobalISel/MIRPatterns.rst (+18) 


``````````diff
diff --git a/llvm/docs/GlobalISel/MIRPatterns.rst b/llvm/docs/GlobalISel/MIRPatterns.rst
index 728e3247014452..97717005ebd619 100644
--- a/llvm/docs/GlobalISel/MIRPatterns.rst
+++ b/llvm/docs/GlobalISel/MIRPatterns.rst
@@ -514,3 +514,21 @@ 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)
+
+(match (wip_match_opcode G_ZEXT):$root,
+
+(match (G_TRUNC $src, $x),
+       (G_ZEXT $root, $src),
+
+(match (G_TRUNC $src, $x, (MIFlags NoUWrap)),
+       (G_ZEXT $root, $src),

``````````

</details>


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


More information about the llvm-commits mailing list