[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 Apr 12 21:03:07 PDT 2025
================
@@ -1033,6 +1033,24 @@ def funnel_shift_overshift: GICombineRule<
(apply [{ Helper.applyFunnelShiftConstantModulo(*${root}); }])
>;
+// Transform: fshl x, ?, y | shl x, y -> fshl x, ?, y
+def funnel_shift_or_shift_to_funnel_shift_left: GICombineRule<
+ (defs root:$root),
+ (match (G_FSHL $out1, $x, $_, $y),
+ (G_SHL $out2, $x, $y),
+ (G_OR $root, $out1, $out2)),
+ (apply (G_FSHL $root, $x, $_, $y))
+>;
+
+// Transform: fshr ?, x, y | srl x, y -> fshr ?, x, y
+def funnel_shift_or_shift_to_funnel_shift_right: GICombineRule<
+ (defs root:$root),
+ (match (G_FSHR $out1, $_, $x, $y),
+ (G_LSHR $out2, $x, $y),
+ (G_OR $root, $out1, $out2)),
----------------
axelcool1234 wrote:
> Missing hasOneUse checks?
The original SelectionDAG ISel didn't have a check for this. I do see how it'd be problematic for the `G_OR` and `G_LSHR` statements to be removed if later code relied on them. How did the SelectionDAG ISel combiner not case this problem?
I also couldn't manage to find any Tablegen code utilizing `hasOneUse`. If you have any resources or examples, I'd be immensely grateful!
https://github.com/llvm/llvm-project/pull/135132
More information about the llvm-commits
mailing list