While working on PR 111972, I was getting a regression due to zero_one_valued_p matching a signed 1 bit integer when it came to convert. This patch fixes that by checking the outer type too.
Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * match.pd (zero_one_valued_p): For convert make sure type is not a signed 1-bit integer. Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com> --- gcc/match.pd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/match.pd b/gcc/match.pd index 26383e55767..4d554ba4721 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -2247,6 +2247,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (INTEGRAL_TYPE_P (TREE_TYPE (@1)) && (TYPE_UNSIGNED (TREE_TYPE (@1)) || TYPE_PRECISION (TREE_TYPE (@1)) > 1) + && INTEGRAL_TYPE_P (type) + && (TYPE_UNSIGNED (type) + || TYPE_PRECISION (type) > 1) && wi::leu_p (tree_nonzero_bits (@1), 1)))) /* Transform { 0 or 1 } * { 0 or 1 } into { 0 or 1 } & { 0 or 1 }. */ -- 2.39.3