[llvm] [GlobalIsel][NFC] Refactor ext of trunc (PR #92533)

via llvm-commits llvm-commits at lists.llvm.org
Fri May 17 05:51:23 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/92533.diff


1 Files Affected:

- (modified) llvm/include/llvm/Target/GlobalISel/Combine.td (+8-6) 


``````````diff
diff --git a/llvm/include/llvm/Target/GlobalISel/Combine.td b/llvm/include/llvm/Target/GlobalISel/Combine.td
index a1d39d910bc8e..8364a9ae3b76d 100644
--- a/llvm/include/llvm/Target/GlobalISel/Combine.td
+++ b/llvm/include/llvm/Target/GlobalISel/Combine.td
@@ -735,18 +735,20 @@ def redundant_sext_inreg: GICombineRule <
 // the destination type.
 def anyext_trunc_fold: GICombineRule <
   (defs root:$root, register_matchinfo:$matchinfo),
-  (match (wip_match_opcode G_ANYEXT):$root,
-         [{ return Helper.matchCombineAnyExtTrunc(*${root}, ${matchinfo}); }]),
-  (apply [{ Helper.replaceSingleDefInstWithReg(*${root}, ${matchinfo}); }])
+  (match (G_TRUNC $input, $x),
+         (G_ANYEXT $root, $input):$mi,
+         [{ return Helper.matchCombineAnyExtTrunc(*${mi}, ${matchinfo}); }]),
+  (apply [{ Helper.replaceSingleDefInstWithReg(*${mi}, ${matchinfo}); }])
 >;
 
 // Fold (zext (trunc x)) -> x if the source type is same as the destination type
 // and truncated bits are known to be zero.
 def zext_trunc_fold: GICombineRule <
   (defs root:$root, register_matchinfo:$matchinfo),
-  (match (wip_match_opcode G_ZEXT):$root,
-         [{ return Helper.matchCombineZextTrunc(*${root}, ${matchinfo}); }]),
-  (apply [{ Helper.replaceSingleDefInstWithReg(*${root}, ${matchinfo}); }])
+  (match (G_TRUNC $input, $x),
+         (G_ZEXT $root, $input):$mi,
+         [{ return Helper.matchCombineZextTrunc(*${mi}, ${matchinfo}); }]),
+  (apply [{ Helper.replaceSingleDefInstWithReg(*${mi}, ${matchinfo}); }])
 >;
 
 // Fold ([asz]ext ([asz]ext x)) -> ([asz]ext x).

``````````

</details>


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


More information about the llvm-commits mailing list