diff mbox series

aarch64: Fix ICE in aarch64_add_offset_1_temporaries [PR100302]

Message ID 20210429090523.GF1179226@tucnak
State New
Headers show
Series aarch64: Fix ICE in aarch64_add_offset_1_temporaries [PR100302] | expand

Commit Message

Jakub Jelinek April 29, 2021, 9:05 a.m. UTC
Hi!

In PR94121 I've changed aarch64_add_offset_1 to use absu_hwi instead of
abs_hwi because offset can be HOST_WIDE_INT_MIN.  As can be seen with
the testcase below, aarch64_add_offset_1_temporaries suffers from the same
problem and should be in sync with aarch64_add_offset_1, i.e. for
HOST_WIDE_INT_MIN it needs a temporary.

Bootstrapped/regtested on aarch64-linux, ok for trunk?

2021-04-29  Jakub Jelinek  <jakub@redhat.com>

	PR target/100302
	* config/aarch64/aarch64.c (aarch64_add_offset_1_temporaries): Use
	absu_hwi instead of abs_hwi.

	* gcc.target/aarch64/sve/pr100302.c: New test.


	Jakub

Comments

Richard Sandiford April 29, 2021, 9:07 a.m. UTC | #1
Jakub Jelinek <jakub@redhat.com> writes:
> Hi!
>
> In PR94121 I've changed aarch64_add_offset_1 to use absu_hwi instead of
> abs_hwi because offset can be HOST_WIDE_INT_MIN.  As can be seen with
> the testcase below, aarch64_add_offset_1_temporaries suffers from the same
> problem and should be in sync with aarch64_add_offset_1, i.e. for
> HOST_WIDE_INT_MIN it needs a temporary.
>
> Bootstrapped/regtested on aarch64-linux, ok for trunk?
>
> 2021-04-29  Jakub Jelinek  <jakub@redhat.com>
>
> 	PR target/100302
> 	* config/aarch64/aarch64.c (aarch64_add_offset_1_temporaries): Use
> 	absu_hwi instead of abs_hwi.
>
> 	* gcc.target/aarch64/sve/pr100302.c: New test.

OK, thanks.

Richard

> --- gcc/config/aarch64/aarch64.c.jj	2021-04-28 10:43:06.313337362 +0200
> +++ gcc/config/aarch64/aarch64.c	2021-04-28 11:01:10.567243000 +0200
> @@ -4736,7 +4736,7 @@ aarch64_mov128_immediate (rtx imm)
>  static unsigned int
>  aarch64_add_offset_1_temporaries (HOST_WIDE_INT offset)
>  {
> -  return abs_hwi (offset) < 0x1000000 ? 0 : 1;
> +  return absu_hwi (offset) < 0x1000000 ? 0 : 1;
>  }
>  
>  /* A subroutine of aarch64_add_offset.  Set DEST to SRC + OFFSET for
> --- gcc/testsuite/gcc.target/aarch64/sve/pr100302.c.jj	2021-04-28 10:49:19.337176274 +0200
> +++ gcc/testsuite/gcc.target/aarch64/sve/pr100302.c	2021-04-28 10:42:48.342537828 +0200
> @@ -0,0 +1,12 @@
> +/* PR target/100302 */
> +/* { dg-do compile } */
> +/* { dg-options "-march=armv8.2-a+sve -O1 -ftree-loop-vectorize -fno-tree-scev-cprop --param vect-partial-vector-usage=0 -fvect-cost-model=unlimited" } */
> +
> +long int x;
> +
> +void
> +foo (void)
> +{
> +  for (x = 0; x >= 0; ++x)
> +    ;
> +}
>
> 	Jakub
diff mbox series

Patch

--- gcc/config/aarch64/aarch64.c.jj	2021-04-28 10:43:06.313337362 +0200
+++ gcc/config/aarch64/aarch64.c	2021-04-28 11:01:10.567243000 +0200
@@ -4736,7 +4736,7 @@  aarch64_mov128_immediate (rtx imm)
 static unsigned int
 aarch64_add_offset_1_temporaries (HOST_WIDE_INT offset)
 {
-  return abs_hwi (offset) < 0x1000000 ? 0 : 1;
+  return absu_hwi (offset) < 0x1000000 ? 0 : 1;
 }
 
 /* A subroutine of aarch64_add_offset.  Set DEST to SRC + OFFSET for
--- gcc/testsuite/gcc.target/aarch64/sve/pr100302.c.jj	2021-04-28 10:49:19.337176274 +0200
+++ gcc/testsuite/gcc.target/aarch64/sve/pr100302.c	2021-04-28 10:42:48.342537828 +0200
@@ -0,0 +1,12 @@ 
+/* PR target/100302 */
+/* { dg-do compile } */
+/* { dg-options "-march=armv8.2-a+sve -O1 -ftree-loop-vectorize -fno-tree-scev-cprop --param vect-partial-vector-usage=0 -fvect-cost-model=unlimited" } */
+
+long int x;
+
+void
+foo (void)
+{
+  for (x = 0; x >= 0; ++x)
+    ;
+}