@@ -945,6 +945,37 @@ def redundant_binop_in_equality : GICombineRule<
945
945
[{ return Helper.matchRedundantBinOpInEquality(*${root}, ${info}); }]),
946
946
(apply [{ Helper.applyBuildFn(*${root}, ${info}); }])>;
947
947
948
+ // Transform: (X == 0 & Y == 0) -> (X | Y) == 0
949
+ def double_icmp_zero_and_combine: GICombineRule<
950
+ (defs root:$root),
951
+ (match (G_ICMP $d1, $p, $s1, 0),
952
+ (G_ICMP $d2, $p, $s2, 0),
953
+ (G_AND $root, $d1, $d2),
954
+ [{ return ${p}.getPredicate() == CmpInst::ICMP_EQ &&
955
+ !MRI.getType(${s1}.getReg()).isPointer() &&
956
+ (MRI.getType(${s1}.getReg()) ==
957
+ MRI.getType(${s2}.getReg())); }]),
958
+ (apply (G_OR $ordst, $s1, $s2),
959
+ (G_ICMP $root, $p, $ordst, 0))
960
+ >;
961
+
962
+ // Transform: (X != 0 | Y != 0) -> (X | Y) != 0
963
+ def double_icmp_zero_or_combine: GICombineRule<
964
+ (defs root:$root),
965
+ (match (G_ICMP $d1, $p, $s1, 0),
966
+ (G_ICMP $d2, $p, $s2, 0),
967
+ (G_OR $root, $d1, $d2),
968
+ [{ return ${p}.getPredicate() == CmpInst::ICMP_NE &&
969
+ !MRI.getType(${s1}.getReg()).isPointer() &&
970
+ (MRI.getType(${s1}.getReg()) ==
971
+ MRI.getType(${s2}.getReg())); }]),
972
+ (apply (G_OR $ordst, $s1, $s2),
973
+ (G_ICMP $root, $p, $ordst, 0))
974
+ >;
975
+
976
+ def double_icmp_zero_and_or_combine : GICombineGroup<[double_icmp_zero_and_combine,
977
+ double_icmp_zero_or_combine]>;
978
+
948
979
def and_or_disjoint_mask : GICombineRule<
949
980
(defs root:$root, build_fn_matchinfo:$info),
950
981
(match (wip_match_opcode G_AND):$root,
@@ -1314,7 +1345,7 @@ def all_combines : GICombineGroup<[trivial_combines, insert_vec_elt_combines,
1314
1345
intdiv_combines, mulh_combines, redundant_neg_operands,
1315
1346
and_or_disjoint_mask, fma_combines, fold_binop_into_select,
1316
1347
sub_add_reg, select_to_minmax, redundant_binop_in_equality,
1317
- fsub_to_fneg, commute_constant_to_rhs]>;
1348
+ double_icmp_zero_and_or_combine, fsub_to_fneg, commute_constant_to_rhs]>;
1318
1349
1319
1350
// A combine group used to for prelegalizer combiners at -O0. The combines in
1320
1351
// this group have been selected based on experiments to balance code size and
0 commit comments