[llvm] [GlobalIsel][NFC] Refactor ext of trunc (PR #92533)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Mon May 20 03:23:43 PDT 2024
================
@@ -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),
----------------
jayfoad wrote:
@Pierre-vh am I right in thinking that a pattern like this:
```
(match (G_TRUNC $input, $x),
(G_ANYEXT $root, $input):$mi,
```
use GIM_RecordInsn**IgnoreCopies** to check that `$input` matches? (I can't see exactly where this is implemented, nor find any discussion of it.)
If so then I think this patch is probably fine and you can remove most of the C++ matching code. All you need to check is that the source type of the trunc matches the dest type of the ext.
https://github.com/llvm/llvm-project/pull/92533
More information about the llvm-commits
mailing list