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

Thorsten Schütt via llvm-commits llvm-commits at lists.llvm.org
Fri May 17 05:50:53 PDT 2024


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

None

>From 3731357a64784dcdaac9623ed5fe926ae4c9400c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thorsten=20Sch=C3=BCtt?= <schuett at gmail.com>
Date: Fri, 17 May 2024 14:49:10 +0200
Subject: [PATCH] [GlobalIsel][NFC] Refactor ext of trunc

---
 llvm/include/llvm/Target/GlobalISel/Combine.td | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

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).



More information about the llvm-commits mailing list