public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix aarch64_simd_reg_or_zero predicate (PR fortran/84565)
@ 2018-02-27  9:50 Jakub Jelinek
  2018-02-27 14:22 ` Richard Sandiford
  2018-03-06 16:13 ` Patch ping (Re: [PATCH] Fix aarch64_simd_reg_or_zero predicate (PR fortran/84565)) Jakub Jelinek
  0 siblings, 2 replies; 5+ messages in thread
From: Jakub Jelinek @ 2018-02-27  9:50 UTC (permalink / raw)
  To: Richard Earnshaw, James Greenhalgh, Marcus Shawcroft, Richard Sandiford
  Cc: gcc-patches

Hi!

The following testcase ICEs, because the aarch64_cmeqdf instruction
starting with r256612 no longer accepts CONST0_RTX (E_DFmode) as
valid argument, but the expander generates it anyway.

The bug has been introduced during the addition of aarch64_simd_imm_zero
and aarch64_simd_or_scalar_imm_zero predicates, before the predicate
used to be:
(define_predicate "aarch64_simd_reg_or_zero"
  (and (match_code "reg,subreg,const_int,const_double,const_vector")
       (ior (match_operand 0 "register_operand")
           (ior (match_test "op == const0_rtx")
                (match_test "aarch64_simd_imm_zero_p (op, mode)")))))
with
bool
aarch64_simd_imm_zero_p (rtx x, machine_mode mode)
{
  return x == CONST0_RTX (mode);
}
and so matched not just const,const_vector zeros, but also
const_int zero (that is through op == const0_rtx) and const_double
zero too.

Bootstrapped/regtested on aarch64-linux (scratch Fedora gcc 8 package build
with the patch applied), ok for trunk?

2018-02-27  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/84565
	* config/aarch64/predicates.md (aarch64_simd_reg_or_zero): Use
	aarch64_simd_or_scalar_imm_zero rather than aarch64_simd_imm_zero.

	* gfortran.dg/pr84565.f90: New test.

--- gcc/config/aarch64/predicates.md.jj	2018-02-06 13:13:06.305751221 +0100
+++ gcc/config/aarch64/predicates.md	2018-02-26 16:30:01.902195208 +0100
@@ -395,7 +395,7 @@ (define_predicate "aarch64_simd_reg_or_z
   (and (match_code "reg,subreg,const_int,const_double,const,const_vector")
        (ior (match_operand 0 "register_operand")
 	    (match_test "op == const0_rtx")
-	    (match_operand 0 "aarch64_simd_imm_zero"))))
+	    (match_operand 0 "aarch64_simd_or_scalar_imm_zero"))))
 
 (define_predicate "aarch64_simd_struct_operand"
   (and (match_code "mem")
--- gcc/testsuite/gfortran.dg/pr84565.f90.jj	2018-02-26 16:32:49.912271950 +0100
+++ gcc/testsuite/gfortran.dg/pr84565.f90	2018-02-26 16:31:15.423223943 +0100
@@ -0,0 +1,7 @@
+! PR fortran/84565
+! { dg-do compile { target aarch64*-*-* } }
+! { dg-options "-mlow-precision-sqrt -funsafe-math-optimizations" }
+subroutine mysqrt(a)
+ real(KIND=KIND(0.0D0)) :: a
+ a=sqrt(a)
+end subroutine

	Jakub

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix aarch64_simd_reg_or_zero predicate (PR fortran/84565)
  2018-02-27  9:50 [PATCH] Fix aarch64_simd_reg_or_zero predicate (PR fortran/84565) Jakub Jelinek
@ 2018-02-27 14:22 ` Richard Sandiford
  2018-02-28 21:49   ` Jakub Jelinek
  2018-03-07 10:36   ` James Greenhalgh
  2018-03-06 16:13 ` Patch ping (Re: [PATCH] Fix aarch64_simd_reg_or_zero predicate (PR fortran/84565)) Jakub Jelinek
  1 sibling, 2 replies; 5+ messages in thread
From: Richard Sandiford @ 2018-02-27 14:22 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: Richard Earnshaw, James Greenhalgh, Marcus Shawcroft, gcc-patches

Jakub Jelinek <jakub@redhat.com> writes:
> Hi!
>
> The following testcase ICEs, because the aarch64_cmeqdf instruction
> starting with r256612 no longer accepts CONST0_RTX (E_DFmode) as
> valid argument, but the expander generates it anyway.
>
> The bug has been introduced during the addition of aarch64_simd_imm_zero
> and aarch64_simd_or_scalar_imm_zero predicates, before the predicate
> used to be:
> (define_predicate "aarch64_simd_reg_or_zero"
>   (and (match_code "reg,subreg,const_int,const_double,const_vector")
>        (ior (match_operand 0 "register_operand")
>            (ior (match_test "op == const0_rtx")
>                 (match_test "aarch64_simd_imm_zero_p (op, mode)")))))
> with
> bool
> aarch64_simd_imm_zero_p (rtx x, machine_mode mode)
> {
>   return x == CONST0_RTX (mode);
> }
> and so matched not just const,const_vector zeros, but also
> const_int zero (that is through op == const0_rtx) and const_double
> zero too.

Thanks for fixing this.

> Bootstrapped/regtested on aarch64-linux (scratch Fedora gcc 8 package build
> with the patch applied), ok for trunk?
>
> 2018-02-27  Jakub Jelinek  <jakub@redhat.com>
>
> 	PR fortran/84565
> 	* config/aarch64/predicates.md (aarch64_simd_reg_or_zero): Use
> 	aarch64_simd_or_scalar_imm_zero rather than aarch64_simd_imm_zero.
>
> 	* gfortran.dg/pr84565.f90: New test.
>
> --- gcc/config/aarch64/predicates.md.jj	2018-02-06 13:13:06.305751221 +0100
> +++ gcc/config/aarch64/predicates.md	2018-02-26 16:30:01.902195208 +0100
> @@ -395,7 +395,7 @@ (define_predicate "aarch64_simd_reg_or_z
>    (and (match_code "reg,subreg,const_int,const_double,const,const_vector")
>         (ior (match_operand 0 "register_operand")
>  	    (match_test "op == const0_rtx")
> -	    (match_operand 0 "aarch64_simd_imm_zero"))))
> +	    (match_operand 0 "aarch64_simd_or_scalar_imm_zero"))))

I think this makes the match_test on the line above redundant.

LGTM otherwise (but I can't approve).  We should probably clean up
the predicates so that the zero checks are more consistent.  genrecog
could probably help by ignoring predicate codes that obviously don't
apply (CONST_INT for vectors, CONST_VECTOR for ints, etc.).  But that's
obviously all stage 1 stuff.

Richard

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix aarch64_simd_reg_or_zero predicate (PR fortran/84565)
  2018-02-27 14:22 ` Richard Sandiford
@ 2018-02-28 21:49   ` Jakub Jelinek
  2018-03-07 10:36   ` James Greenhalgh
  1 sibling, 0 replies; 5+ messages in thread
From: Jakub Jelinek @ 2018-02-28 21:49 UTC (permalink / raw)
  To: Richard Earnshaw, James Greenhalgh, Marcus Shawcroft,
	gcc-patches, richard.sandiford

On Tue, Feb 27, 2018 at 02:22:22PM +0000, Richard Sandiford wrote:
> > Bootstrapped/regtested on aarch64-linux (scratch Fedora gcc 8 package build
> > with the patch applied), ok for trunk?
> >
> > 2018-02-27  Jakub Jelinek  <jakub@redhat.com>
> >
> > 	PR fortran/84565
> > 	* config/aarch64/predicates.md (aarch64_simd_reg_or_zero): Use
> > 	aarch64_simd_or_scalar_imm_zero rather than aarch64_simd_imm_zero.
> >
> > 	* gfortran.dg/pr84565.f90: New test.
> >
> > --- gcc/config/aarch64/predicates.md.jj	2018-02-06 13:13:06.305751221 +0100
> > +++ gcc/config/aarch64/predicates.md	2018-02-26 16:30:01.902195208 +0100
> > @@ -395,7 +395,7 @@ (define_predicate "aarch64_simd_reg_or_z
> >    (and (match_code "reg,subreg,const_int,const_double,const,const_vector")
> >         (ior (match_operand 0 "register_operand")
> >  	    (match_test "op == const0_rtx")
> > -	    (match_operand 0 "aarch64_simd_imm_zero"))))
> > +	    (match_operand 0 "aarch64_simd_or_scalar_imm_zero"))))
> 
> I think this makes the match_test on the line above redundant.

Yes, it is; it used to be redundant before too.  I can change it if needed,
it would be just a matter of dropping the (match_test "op == const0_rtx")
line.

	Jakub

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Patch ping (Re: [PATCH] Fix aarch64_simd_reg_or_zero predicate (PR fortran/84565))
  2018-02-27  9:50 [PATCH] Fix aarch64_simd_reg_or_zero predicate (PR fortran/84565) Jakub Jelinek
  2018-02-27 14:22 ` Richard Sandiford
@ 2018-03-06 16:13 ` Jakub Jelinek
  1 sibling, 0 replies; 5+ messages in thread
From: Jakub Jelinek @ 2018-03-06 16:13 UTC (permalink / raw)
  To: Richard Earnshaw, James Greenhalgh, Marcus Shawcroft; +Cc: gcc-patches

Hi!

I'd like to ping this patch, without or with the additional redundant
(match_test "op == const0_rtx")
line removal.

> Bootstrapped/regtested on aarch64-linux (scratch Fedora gcc 8 package build
> with the patch applied), ok for trunk?
> 
> 2018-02-27  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR fortran/84565
> 	* config/aarch64/predicates.md (aarch64_simd_reg_or_zero): Use
> 	aarch64_simd_or_scalar_imm_zero rather than aarch64_simd_imm_zero.
> 
> 	* gfortran.dg/pr84565.f90: New test.
> 
> --- gcc/config/aarch64/predicates.md.jj	2018-02-06 13:13:06.305751221 +0100
> +++ gcc/config/aarch64/predicates.md	2018-02-26 16:30:01.902195208 +0100
> @@ -395,7 +395,7 @@ (define_predicate "aarch64_simd_reg_or_z
>    (and (match_code "reg,subreg,const_int,const_double,const,const_vector")
>         (ior (match_operand 0 "register_operand")
>  	    (match_test "op == const0_rtx")
> -	    (match_operand 0 "aarch64_simd_imm_zero"))))
> +	    (match_operand 0 "aarch64_simd_or_scalar_imm_zero"))))
>  
>  (define_predicate "aarch64_simd_struct_operand"
>    (and (match_code "mem")
> --- gcc/testsuite/gfortran.dg/pr84565.f90.jj	2018-02-26 16:32:49.912271950 +0100
> +++ gcc/testsuite/gfortran.dg/pr84565.f90	2018-02-26 16:31:15.423223943 +0100
> @@ -0,0 +1,7 @@
> +! PR fortran/84565
> +! { dg-do compile { target aarch64*-*-* } }
> +! { dg-options "-mlow-precision-sqrt -funsafe-math-optimizations" }
> +subroutine mysqrt(a)
> + real(KIND=KIND(0.0D0)) :: a
> + a=sqrt(a)
> +end subroutine

	Jakub

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix aarch64_simd_reg_or_zero predicate (PR fortran/84565)
  2018-02-27 14:22 ` Richard Sandiford
  2018-02-28 21:49   ` Jakub Jelinek
@ 2018-03-07 10:36   ` James Greenhalgh
  1 sibling, 0 replies; 5+ messages in thread
From: James Greenhalgh @ 2018-03-07 10:36 UTC (permalink / raw)
  To: Jakub Jelinek, Richard Earnshaw, Marcus Shawcroft, gcc-patches,
	richard.sandiford
  Cc: nd

On Tue, Feb 27, 2018 at 02:22:22PM +0000, Richard Sandiford wrote:
> Jakub Jelinek <jakub@redhat.com> writes:
> > Hi!
> >
> > The following testcase ICEs, because the aarch64_cmeqdf instruction
> > starting with r256612 no longer accepts CONST0_RTX (E_DFmode) as
> > valid argument, but the expander generates it anyway.
> >
> > The bug has been introduced during the addition of aarch64_simd_imm_zero
> > and aarch64_simd_or_scalar_imm_zero predicates, before the predicate
> > used to be:
> > (define_predicate "aarch64_simd_reg_or_zero"
> >   (and (match_code "reg,subreg,const_int,const_double,const_vector")
> >        (ior (match_operand 0 "register_operand")
> >            (ior (match_test "op == const0_rtx")
> >                 (match_test "aarch64_simd_imm_zero_p (op, mode)")))))
> > with
> > bool
> > aarch64_simd_imm_zero_p (rtx x, machine_mode mode)
> > {
> >   return x == CONST0_RTX (mode);
> > }
> > and so matched not just const,const_vector zeros, but also
> > const_int zero (that is through op == const0_rtx) and const_double
> > zero too.
> 
> Thanks for fixing this.
> 
> > Bootstrapped/regtested on aarch64-linux (scratch Fedora gcc 8 package build
> > with the patch applied), ok for trunk?
> >
> > 2018-02-27  Jakub Jelinek  <jakub@redhat.com>
> >
> > 	PR fortran/84565
> > 	* config/aarch64/predicates.md (aarch64_simd_reg_or_zero): Use
> > 	aarch64_simd_or_scalar_imm_zero rather than aarch64_simd_imm_zero.
> >
> > 	* gfortran.dg/pr84565.f90: New test.
> >
> > --- gcc/config/aarch64/predicates.md.jj	2018-02-06 13:13:06.305751221 +0100
> > +++ gcc/config/aarch64/predicates.md	2018-02-26 16:30:01.902195208 +0100
> > @@ -395,7 +395,7 @@ (define_predicate "aarch64_simd_reg_or_z
> >    (and (match_code "reg,subreg,const_int,const_double,const,const_vector")
> >         (ior (match_operand 0 "register_operand")
> >  	    (match_test "op == const0_rtx")
> > -	    (match_operand 0 "aarch64_simd_imm_zero"))))
> > +	    (match_operand 0 "aarch64_simd_or_scalar_imm_zero"))))
> 
> I think this makes the match_test on the line above redundant.
> 
> LGTM otherwise (but I can't approve).  We should probably clean up
> the predicates so that the zero checks are more consistent.  genrecog
> could probably help by ignoring predicate codes that obviously don't
> apply (CONST_INT for vectors, CONST_VECTOR for ints, etc.).  But that's
> obviously all stage 1 stuff.

OK.

Thanks,
James

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-07 10:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-27  9:50 [PATCH] Fix aarch64_simd_reg_or_zero predicate (PR fortran/84565) Jakub Jelinek
2018-02-27 14:22 ` Richard Sandiford
2018-02-28 21:49   ` Jakub Jelinek
2018-03-07 10:36   ` James Greenhalgh
2018-03-06 16:13 ` Patch ping (Re: [PATCH] Fix aarch64_simd_reg_or_zero predicate (PR fortran/84565)) Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).