[llvm] [GlobalIsel] Combine cast of const integer. (PR #96139)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 21 01:38:23 PDT 2024


================
@@ -1758,6 +1758,34 @@ def freeze_combines: GICombineGroup<[
   push_freeze_to_prevent_poison_from_propagating
 ]>;
 
+def ZextInteger: GICombineRule<
+   (defs root:$root, apint_matchinfo:$matchinfo),
+   (match (G_CONSTANT $int, $imm),
+          (G_ZEXT $root, $int):$mi,
+   [{ return Helper.matchZextInteger(*${mi}, ${matchinfo}); }]),
+   (apply [{ Helper.replaceInstWithConstant(*${mi}, ${matchinfo}); }])>;
+
+def SextInteger: GICombineRule<
+   (defs root:$root, apint_matchinfo:$matchinfo),
+   (match (G_CONSTANT $int, $imm),
+          (G_SEXT $root, $int):$mi,
+   [{ return Helper.matchSextInteger(*${mi}, ${matchinfo}); }]),
+   (apply [{ Helper.replaceInstWithConstant(*${mi}, ${matchinfo}); }])>;
+
+def TruncInteger: GICombineRule<
+   (defs root:$root, apint_matchinfo:$matchinfo),
+   (match (G_CONSTANT $int, $imm),
+          (G_TRUNC $root, $int):$mi,
+   [{ return Helper.matchTruncInteger(*${mi}, ${matchinfo}); }]),
+   (apply [{ Helper.replaceInstWithConstant(*${mi}, ${matchinfo}); }])>;
+
+def cast_const_combines: GICombineGroup<[
+  ZextInteger,
+  SextInteger,
+  TruncInteger,
----------------
arsenm wrote:

No trailing comma? 

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


More information about the llvm-commits mailing list