From: Andrew Pinski Date: Wed, 7 Jun 2023 14:43:50 +0000 (-0700) Subject: Change the `(zero_one ==/!= 0) ? y : z y` patterns to use multiply rather than... X-Git-Tag: basepoints/gcc-15~8484 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52c92fb3f4005051e86bb3e9c70a13fb34954cd1;p=thirdparty%2Fgcc.git Change the `(zero_one ==/!= 0) ? y : z y` patterns to use multiply rather than `(-zero_one) & z` Since there is a pattern to convert `(-zero_one) & z` into `zero_one * z` already, it is better if we don't do a secondary transformation. This reduces the extra statements produced by match-and-simplify on the gimple level too. gcc/ChangeLog: * match.pd ((zero_one ==/!= 0) ? y : z y): Use multiply rather than negation/bit_and. --- diff --git a/gcc/match.pd b/gcc/match.pd index 77030b3b50b9..610668d562cb 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3695,7 +3695,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (cond (le @0 integer_zerop@1) (negate@2 @0) integer_zerop@1) (max @2 @1)) -/* (zero_one == 0) ? y : z y -> (-(typeof(y))zero_one & z) y */ +/* (zero_one == 0) ? y : z y -> ((typeof(y))zero_one * z) y */ (for op (bit_xor bit_ior) (simplify (cond (eq zero_one_valued_p@0 @@ -3705,9 +3705,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (INTEGRAL_TYPE_P (type) && TYPE_PRECISION (type) > 1 && (INTEGRAL_TYPE_P (TREE_TYPE (@0)))) - (op (bit_and (negate (convert:type @0)) @2) @1)))) + (op (mult (convert:type @0) @2) @1)))) -/* (zero_one != 0) ? z y : y -> (-(typeof(y))zero_one & z) y */ +/* (zero_one != 0) ? z y : y -> ((typeof(y))zero_one * z) y */ (for op (bit_xor bit_ior) (simplify (cond (ne zero_one_valued_p@0 @@ -3717,7 +3717,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (INTEGRAL_TYPE_P (type) && TYPE_PRECISION (type) > 1 && (INTEGRAL_TYPE_P (TREE_TYPE (@0)))) - (op (bit_and (negate (convert:type @0)) @2) @1)))) + (op (mult (convert:type @0) @2) @1)))) /* Simplifications of shift and rotates. */