@@ -1040,6 +1040,34 @@ def funnel_shift_overshift: GICombineRule<
10401040 (apply [{ Helper.applyFunnelShiftConstantModulo(*${root}); }])
10411041>;
10421042
1043+ // Transform: fshl x, z, y | shl x, y -> fshl x, z, y
1044+ // Transform: shl x, y | fshl x, z, y -> fshl x, z, y
1045+ // FIXME: TableGen didn't handle G_OR commutativity on its own,
1046+ // necessitating the use of !foreach to handle it manually.
1047+ def funnel_shift_or_shift_to_funnel_shift_left_frags : GICombinePatFrag<
1048+ (outs root: $dst, $out1, $out2), (ins),
1049+ !foreach(inst, [(G_OR $dst, $out1, $out2), (G_OR $dst, $out2, $out1)],
1050+ (pattern (G_FSHL $out1, $x, $z, $y), (G_SHL $out2, $x, $y), inst))>;
1051+ def funnel_shift_or_shift_to_funnel_shift_left: GICombineRule<
1052+ (defs root:$root),
1053+ (match (funnel_shift_or_shift_to_funnel_shift_left_frags $root, $out1, $out2)),
1054+ (apply (GIReplaceReg $root, $out1))
1055+ >;
1056+
1057+ // Transform: fshr z, x, y | srl x, y -> fshr z, x, y
1058+ // Transform: srl x, y | fshr z, x, y -> fshr z, x, y
1059+ // FIXME: TableGen didn't handle G_OR commutativity on its own,
1060+ // necessitating the use of !foreach to handle it manually.
1061+ def funnel_shift_or_shift_to_funnel_shift_right_frags : GICombinePatFrag<
1062+ (outs root: $dst, $out1, $out2), (ins),
1063+ !foreach(inst, [(G_OR $dst, $out1, $out2), (G_OR $dst, $out2, $out1)],
1064+ (pattern (G_FSHR $out1, $z, $x, $y), (G_LSHR $out2, $x, $y), inst))>;
1065+ def funnel_shift_or_shift_to_funnel_shift_right: GICombineRule<
1066+ (defs root:$root),
1067+ (match (funnel_shift_or_shift_to_funnel_shift_right_frags $root, $out1, $out2)),
1068+ (apply (GIReplaceReg $root, $out1))
1069+ >;
1070+
10431071def rotate_out_of_range : GICombineRule<
10441072 (defs root:$root),
10451073 (match (wip_match_opcode G_ROTR, G_ROTL):$root,
@@ -1112,7 +1140,9 @@ def funnel_shift_combines : GICombineGroup<[funnel_shift_from_or_shift,
11121140 funnel_shift_to_rotate,
11131141 funnel_shift_right_zero,
11141142 funnel_shift_left_zero,
1115- funnel_shift_overshift]>;
1143+ funnel_shift_overshift,
1144+ funnel_shift_or_shift_to_funnel_shift_left,
1145+ funnel_shift_or_shift_to_funnel_shift_right]>;
11161146
11171147def bitfield_extract_from_sext_inreg : GICombineRule<
11181148 (defs root:$root, build_fn_matchinfo:$info),
0 commit comments