@@ -903,6 +903,37 @@ def redundant_binop_in_equality : GICombineRule<
903
903
[{ return Helper.matchRedundantBinOpInEquality(*${root}, ${info}); }]),
904
904
(apply [{ Helper.applyBuildFn(*${root}, ${info}); }])>;
905
905
906
+ // Transform: (X == 0 & Y == 0) -> (X | Y) == 0
907
+ def double_icmp_zero_and_combine: GICombineRule<
908
+ (defs root:$root),
909
+ (match (G_ICMP $d1, $p, $s1, 0),
910
+ (G_ICMP $d2, $p, $s2, 0),
911
+ (G_AND $root, $d1, $d2),
912
+ [{ return ${p}.getPredicate() == CmpInst::ICMP_EQ &&
913
+ !MRI.getType(${s1}.getReg()).isPointer() &&
914
+ (MRI.getType(${s1}.getReg()) ==
915
+ MRI.getType(${s2}.getReg())); }]),
916
+ (apply (G_OR i32:$ordst, $s1, $s2),
917
+ (G_ICMP $root, $p, $ordst, 0))
918
+ >;
919
+
920
+ // Transform: (X != 0 | Y != 0) -> (X | Y) != 0
921
+ def double_icmp_zero_or_combine: GICombineRule<
922
+ (defs root:$root),
923
+ (match (G_ICMP $d1, $p, $s1, 0),
924
+ (G_ICMP $d2, $p, $s2, 0),
925
+ (G_OR $root, $d1, $d2),
926
+ [{ return ${p}.getPredicate() == CmpInst::ICMP_NE &&
927
+ !MRI.getType(${s1}.getReg()).isPointer() &&
928
+ (MRI.getType(${s1}.getReg()) ==
929
+ MRI.getType(${s2}.getReg())); }]),
930
+ (apply (G_OR i32:$ordst, $s1, $s2),
931
+ (G_ICMP $root, $p, $ordst, 0))
932
+ >;
933
+
934
+ def double_icmp_zero_and_or_combine : GICombineGroup<[double_icmp_zero_and_combine,
935
+ double_icmp_zero_or_combine]>;
936
+
906
937
def and_or_disjoint_mask : GICombineRule<
907
938
(defs root:$root, build_fn_matchinfo:$info),
908
939
(match (wip_match_opcode G_AND):$root,
@@ -1265,7 +1296,7 @@ def all_combines : GICombineGroup<[trivial_combines, insert_vec_elt_combines,
1265
1296
intdiv_combines, mulh_combines, redundant_neg_operands,
1266
1297
and_or_disjoint_mask, fma_combines, fold_binop_into_select,
1267
1298
sub_add_reg, select_to_minmax, redundant_binop_in_equality,
1268
- fsub_to_fneg, commute_constant_to_rhs]>;
1299
+ double_icmp_zero_and_or_combine, fsub_to_fneg, commute_constant_to_rhs]>;
1269
1300
1270
1301
// A combine group used to for prelegalizer combiners at -O0. The combines in
1271
1302
// this group have been selected based on experiments to balance code size and
0 commit comments