Skip to content

[GlobalIsel] Update MIR gallery #107903

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 10, 2024
Merged

[GlobalIsel] Update MIR gallery #107903

merged 2 commits into from
Sep 10, 2024

Conversation

tschuett
Copy link

@tschuett tschuett commented Sep 9, 2024

add more patterns
clarify wip_match_opcode usage

add more patterns
clarify wip_match_opcode usage
@llvmbot
Copy link
Member

llvmbot commented Sep 9, 2024

@llvm/pr-subscribers-llvm-globalisel

Author: Thorsten Schütt (tschuett)

Changes

add more patterns
clarify wip_match_opcode usage


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

1 Files Affected:

  • (modified) llvm/docs/GlobalISel/MIRPatterns.rst (+18-1)
diff --git a/llvm/docs/GlobalISel/MIRPatterns.rst b/llvm/docs/GlobalISel/MIRPatterns.rst
index 654a60730bb9c5..f36ffb889f813d 100644
--- a/llvm/docs/GlobalISel/MIRPatterns.rst
+++ b/llvm/docs/GlobalISel/MIRPatterns.rst
@@ -601,7 +601,7 @@ Gallery
 =======
 
 We should use precise patterns that state our intentions. Please avoid
-using wip_match_opcode in patterns.
+using wip_match_opcode in patterns. It can lead to imprecise patterns.
 
 .. code-block:: text
   :caption: Example fold zext(trunc:nuw)
@@ -630,3 +630,20 @@ using wip_match_opcode in patterns.
            (G_ZEXT $root, $src),
     [{ return Helper.matchZextOfTrunc(${root}, ${matchinfo}); }]),
     (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;
+
+
+  // Precise: lists all combine combinations
+  class ext_of_ext_opcodes<Instruction ext1Opcode, Instruction ext2Opcode> : GICombineRule <
+    (defs root:$root, build_fn_matchinfo:$matchinfo),
+    (match (ext2Opcode $second, $src):$Second,
+         (ext1Opcode $root, $second):$First,
+         [{ return Helper.matchExtOfExt(*${First}, *${Second}, ${matchinfo}); }]),
+    (apply [{ Helper.applyBuildFn(*${First}, ${matchinfo}); }])>;
+
+  def zext_of_zext : ext_of_ext_opcodes<G_ZEXT, G_ZEXT>;
+  def zext_of_anyext : ext_of_ext_opcodes<G_ZEXT, G_ANYEXT>;
+  def sext_of_sext : ext_of_ext_opcodes<G_SEXT, G_SEXT>;
+  def sext_of_anyext : ext_of_ext_opcodes<G_SEXT, G_ANYEXT>;
+  def anyext_of_anyext : ext_of_ext_opcodes<G_ANYEXT, G_ANYEXT>;
+  def anyext_of_zext : ext_of_ext_opcodes<G_ANYEXT, G_ZEXT>;
+  def anyext_of_sext : ext_of_ext_opcodes<G_ANYEXT, G_SEXT>;

@tschuett tschuett requested review from Pierre-vh and arsenm September 9, 2024 19:03
@tschuett tschuett merged commit bece0d7 into llvm:main Sep 10, 2024
9 checks passed
@tschuett tschuett deleted the gisel-gallery2 branch September 10, 2024 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants