]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
MATCH: Fix zero_one_valued_p's convert pattern
authorAndrew Pinski <quic_apinski@quicinc.com>
Sun, 12 Nov 2023 04:33:28 +0000 (20:33 -0800)
committerAndrew Pinski <quic_apinski@quicinc.com>
Mon, 4 Dec 2023 17:30:53 +0000 (09:30 -0800)
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_apinski@quicinc.com>
gcc/match.pd

index 26383e557673cdad5ce4f5c8668ea8eff3c728fd..4d554ba47215fefca386c6f541e4982c68242513 100644 (file)
@@ -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 }.  */