[llvm] [GISel] Combine shift + trunc + shift pattern (PR #155583)

Amara Emerson via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 27 02:53:31 PDT 2025


================
@@ -396,6 +396,14 @@ def commute_shift : GICombineRule<
          [{ return Helper.matchCommuteShift(*${d}, ${matchinfo}); }]),
   (apply [{ Helper.applyBuildFn(*${d}, ${matchinfo}); }])>;
 
+// Fold (shift (trunc (shift x, C1)), C2) -> trunc (shift x, (C1 + C2))
+def shift_of_trunc_of_shift_matchdata : GIDefMatchData<"ShiftOfTruncOfShift">;
+def shift_of_trunc_of_shift : GICombineRule<
+  (defs root:$root, shift_of_trunc_of_shift_matchdata:$matchinfo),
+  (match (wip_match_opcode G_LSHR, G_ASHR):$root,
----------------
aemerson wrote:

We shouldn't be adding new combines with `wip_match_opcode` anymore.

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


More information about the llvm-commits mailing list