* [PATCH] Fix ICE on _Fract division (PR tree-optimization/81428)
@ 2017-07-13 20:41 Jakub Jelinek
2017-07-17 10:07 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2017-07-13 20:41 UTC (permalink / raw)
To: gcc-patches
Hi!
_Fract types can't express 1, other spots that call build_one_cst already
make sure that the type is integral or uses the !ALL_FRACT_MODE_P (TYPE_MODE (type))
check I've added in this patch.
Bootstrapped/regtested on x86_64-linux and i686-linux and tested with a
cross to arm on the testcase. Ok for trunk?
2017-07-13 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/81428
* match.pd (X / X -> one): Don't optimize _Fract divisions, as 1
can't be built for those types.
* gcc.dg/fixed-point/pr81428.c: New test.
--- gcc/match.pd.jj 2017-07-13 15:37:34.000000000 +0200
+++ gcc/match.pd 2017-07-13 15:46:11.194593051 +0200
@@ -243,8 +243,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
/* X / X is one. */
(simplify
(div @0 @0)
- /* But not for 0 / 0 so that we can get the proper warnings and errors. */
- (if (!integer_zerop (@0))
+ /* But not for 0 / 0 so that we can get the proper warnings and errors.
+ And not for _Fract types where we can't build 1. */
+ (if (!integer_zerop (@0) && !ALL_FRACT_MODE_P (TYPE_MODE (type)))
{ build_one_cst (type); }))
/* X / abs (X) is X < 0 ? -1 : 1. */
(simplify
--- gcc/testsuite/gcc.dg/fixed-point/pr81428.c.jj 2017-07-13 15:49:52.980806440 +0200
+++ gcc/testsuite/gcc.dg/fixed-point/pr81428.c 2017-07-13 15:49:29.000000000 +0200
@@ -0,0 +1,9 @@
+/* PR tree-optimization/81428 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+void
+foo (long _Fract *a, long _Fract *b)
+{
+ *b = *a / *a;
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix ICE on _Fract division (PR tree-optimization/81428)
2017-07-13 20:41 [PATCH] Fix ICE on _Fract division (PR tree-optimization/81428) Jakub Jelinek
@ 2017-07-17 10:07 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2017-07-17 10:07 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: GCC Patches
On Thu, Jul 13, 2017 at 10:41 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> _Fract types can't express 1, other spots that call build_one_cst already
> make sure that the type is integral or uses the !ALL_FRACT_MODE_P (TYPE_MODE (type))
> check I've added in this patch.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux and tested with a
> cross to arm on the testcase. Ok for trunk?
Ok.
> 2017-07-13 Jakub Jelinek <jakub@redhat.com>
>
> PR tree-optimization/81428
> * match.pd (X / X -> one): Don't optimize _Fract divisions, as 1
> can't be built for those types.
>
> * gcc.dg/fixed-point/pr81428.c: New test.
>
> --- gcc/match.pd.jj 2017-07-13 15:37:34.000000000 +0200
> +++ gcc/match.pd 2017-07-13 15:46:11.194593051 +0200
> @@ -243,8 +243,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
> /* X / X is one. */
> (simplify
> (div @0 @0)
> - /* But not for 0 / 0 so that we can get the proper warnings and errors. */
> - (if (!integer_zerop (@0))
> + /* But not for 0 / 0 so that we can get the proper warnings and errors.
> + And not for _Fract types where we can't build 1. */
> + (if (!integer_zerop (@0) && !ALL_FRACT_MODE_P (TYPE_MODE (type)))
> { build_one_cst (type); }))
> /* X / abs (X) is X < 0 ? -1 : 1. */
> (simplify
> --- gcc/testsuite/gcc.dg/fixed-point/pr81428.c.jj 2017-07-13 15:49:52.980806440 +0200
> +++ gcc/testsuite/gcc.dg/fixed-point/pr81428.c 2017-07-13 15:49:29.000000000 +0200
> @@ -0,0 +1,9 @@
> +/* PR tree-optimization/81428 */
> +/* { dg-do compile } */
> +/* { dg-options "-O2" } */
> +
> +void
> +foo (long _Fract *a, long _Fract *b)
> +{
> + *b = *a / *a;
> +}
>
> Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-07-17 10:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-13 20:41 [PATCH] Fix ICE on _Fract division (PR tree-optimization/81428) Jakub Jelinek
2017-07-17 10:07 ` Richard Biener
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).