[1/3] MATCH: Fix zero_one_valued_p's convert pattern

Message ID 20231202063725.3405094-2-quic_apinski@quicinc.com
State Committed
Commit 886f256ce3be4aa85f30af88558f0dfcb8003300
Headers
Series Fix PR 111972 |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gcc_check--master-arm success Testing passed

Commit Message

Andrew Pinski Dec. 2, 2023, 6:37 a.m. UTC
  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 | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Richard Biener Dec. 4, 2023, 2:21 p.m. UTC | #1
On Sat, Dec 2, 2023 at 7:38 AM Andrew Pinski <quic_apinski@quicinc.com> wrote:
>
> 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.

OK

> 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 | 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
>
  

Patch

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 }.  */