[llvm] [GISel] Funnel shift combiner port from SelectionDAG ISel to GlobalISel (PR #135132)
Axel Sorenson via llvm-commits
llvm-commits at lists.llvm.org
Sat May 10 04:35:15 PDT 2025
================
@@ -1034,20 +1034,26 @@ def funnel_shift_overshift: GICombineRule<
>;
// Transform: fshl x, z, y | shl x, y -> fshl x, z, y
+// Transform: shl x, y | fshl x, z, y -> fshl x, z, y
+def funnel_shift_or_shift_to_funnel_shift_left_frags : GICombinePatFrag<
+ (outs root: $dst, $out1, $out2), (ins),
+ !foreach(inst, [(G_OR $dst, $out1, $out2), (G_OR $dst, $out2, $out1)],
+ (pattern (G_FSHL $out1, $x, $z, $y), (G_SHL $out2, $x, $y), inst))>;
def funnel_shift_or_shift_to_funnel_shift_left: GICombineRule<
(defs root:$root),
- (match (G_FSHL $out1, $x, $z, $y),
- (G_SHL $out2, $x, $y),
- (G_OR $root, $out1, $out2)),
+ (match (funnel_shift_or_shift_to_funnel_shift_left_frags $root, $out1, $out2)),
(apply (GIReplaceReg $root, $out1))
>;
----------------
axelcool1234 wrote:
This now generates a pattern for both ordering of the `G_OR` instructions' operands. My combines now trigger the AArch test that hasn't been triggering this entire time (which was due to the operands being flipped in the or instruction).
Perhaps there's a better way to write this. Perhaps this is a workaround for something that shouldn't even be a problem (I haven't found any code handling commutativity like this). Please let me know of any improvements or changes I should make to this.
https://github.com/llvm/llvm-project/pull/135132
More information about the llvm-commits
mailing list