diff mbox

PR 70687: Use wide_int in combine.c:change_zero_ext

Message ID 874maffquc.fsf@e105548-lin.cambridge.arm.com
State New
Headers show

Commit Message

Richard Sandiford May 3, 2016, 9:11 a.m. UTC
PR 70687 reports a case where combine.c mishandles integer modes
wider than unsigned HOST_WIDE_INT.  I don't have a testcase since
the PR is just pointing out the hole.

Also, I think a ZERO_EXTEND of a vector mode could in principle satisfy
the subreg condition but wouldn't be equivalent to an AND.  E.g.:

  (zero_extend:V4DI (subreg:V4SI (reg:V4DI R) 0))

Tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard


	PR rtl-optimization/70687
	* combine.c (change_zero_ext): Check for scalar modes.  Use wide_int
	instead of unsigned HOST_WIDE_INT.

Comments

Bernd Schmidt May 3, 2016, 9:43 a.m. UTC | #1
On 05/03/2016 11:11 AM, Richard Sandiford wrote:
> PR 70687 reports a case where combine.c mishandles integer modes
> wider than unsigned HOST_WIDE_INT.  I don't have a testcase since
> the PR is just pointing out the hole.
>
> Also, I think a ZERO_EXTEND of a vector mode could in principle satisfy
> the subreg condition but wouldn't be equivalent to an AND.  E.g.:
>
>    (zero_extend:V4DI (subreg:V4SI (reg:V4DI R) 0))
>
> Tested on x86_64-linux-gnu.  OK to install?
>
> 	PR rtl-optimization/70687
> 	* combine.c (change_zero_ext): Check for scalar modes.  Use wide_int
> 	instead of unsigned HOST_WIDE_INT.

Ok.


Bernd
diff mbox

Patch

diff --git a/gcc/combine.c b/gcc/combine.c
index 1d0e8be..0ab3f97 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -11096,6 +11096,7 @@  change_zero_ext (rtx *src)
 				   XEXP (x, 0), GEN_INT (start));
 	}
       else if (GET_CODE (x) == ZERO_EXTEND
+	       && SCALAR_INT_MODE_P (mode)
 	       && GET_CODE (XEXP (x, 0)) == SUBREG
 	       && GET_MODE (SUBREG_REG (XEXP (x, 0))) == mode
 	       && subreg_lowpart_p (XEXP (x, 0)))
@@ -11106,11 +11107,8 @@  change_zero_ext (rtx *src)
       else
 	continue;
 
-      unsigned HOST_WIDE_INT mask = 1;
-      mask <<= size;
-      mask--;
-
-      x = gen_rtx_AND (mode, x, GEN_INT (mask));
+      wide_int mask = wi::mask (size, false, GET_MODE_PRECISION (mode));
+      x = gen_rtx_AND (mode, x, immed_wide_int_const (mask, mode));
 
       SUBST (**iter, x);
       changed = true;