public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix ICE in x86 DIVMOD libfunc expansion (PR target/88594)
@ 2019-01-03 23:00 Jakub Jelinek
  2019-01-04  7:21 ` Uros Bizjak
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2019-01-03 23:00 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches

Hi!

The following testcase ICEs, because during DIVMOD discovery a is still not
known to be a constant (otherwise we wouldn't create a DIVMOD), but later on
before expansion it is replaced with 17 and ix86_expand_divmod_libfunc
calls emit_library_call_value with GET_MODE (op1) as the mode for the
argument, which is thus VOIDmode, while we want to say that even when the
argument is VOIDmode, the argument is TImode.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2019-01-03  Jakub Jelinek  <jakub@redhat.com>

	PR target/88594
	* config/i386/i386.c (ix86_expand_divmod_libfunc): Use mode instead
	of GET_MODE (opN) as modes of the libcall arguments.

	* gcc.dg/pr88594.c: New test.

--- gcc/config/i386/i386.c.jj	2019-01-03 14:32:43.050093691 +0100
+++ gcc/config/i386/i386.c	2019-01-03 20:15:11.351392235 +0100
@@ -51002,9 +51002,7 @@ ix86_expand_divmod_libfunc (rtx libfunc,
   rtx rem = assign_386_stack_local (mode, SLOT_TEMP);
 
   rtx quot = emit_library_call_value (libfunc, NULL_RTX, LCT_NORMAL,
-				      mode,
-				      op0, GET_MODE (op0),
-				      op1, GET_MODE (op1),
+				      mode, op0, mode, op1, mode,
 				      XEXP (rem, 0), Pmode);
   *quot_p = quot;
   *rem_p = rem;
--- gcc/testsuite/gcc.dg/pr88594.c.jj	2019-01-03 20:29:58.177819386 +0100
+++ gcc/testsuite/gcc.dg/pr88594.c	2019-01-03 20:29:34.209213935 +0100
@@ -0,0 +1,16 @@
+/* PR target/88594 */
+/* { dg-do compile { target int128 } } */
+/* { dg-options "-O2 -fno-tree-dominator-opts -fno-tree-forwprop -fno-tree-vrp" } */
+
+__int128
+foo (__int128 x, __int128 *y)
+{
+  int a;
+  __int128 z, r;
+  for (a = 0; a < 17; ++a)
+    ;
+  z = x / a;
+  r = x % a;
+  *y = z;
+  return r;
+}

	Jakub

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

* Re: [PATCH] Fix ICE in x86 DIVMOD libfunc expansion (PR target/88594)
  2019-01-03 23:00 [PATCH] Fix ICE in x86 DIVMOD libfunc expansion (PR target/88594) Jakub Jelinek
@ 2019-01-04  7:21 ` Uros Bizjak
  0 siblings, 0 replies; 2+ messages in thread
From: Uros Bizjak @ 2019-01-04  7:21 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On Fri, Jan 4, 2019 at 12:00 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> The following testcase ICEs, because during DIVMOD discovery a is still not
> known to be a constant (otherwise we wouldn't create a DIVMOD), but later on
> before expansion it is replaced with 17 and ix86_expand_divmod_libfunc
> calls emit_library_call_value with GET_MODE (op1) as the mode for the
> argument, which is thus VOIDmode, while we want to say that even when the
> argument is VOIDmode, the argument is TImode.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
>
> 2019-01-03  Jakub Jelinek  <jakub@redhat.com>
>
>         PR target/88594
>         * config/i386/i386.c (ix86_expand_divmod_libfunc): Use mode instead
>         of GET_MODE (opN) as modes of the libcall arguments.
>
>         * gcc.dg/pr88594.c: New test.

OK for trunk and release branches.

Thanks,
Uros.

> --- gcc/config/i386/i386.c.jj   2019-01-03 14:32:43.050093691 +0100
> +++ gcc/config/i386/i386.c      2019-01-03 20:15:11.351392235 +0100
> @@ -51002,9 +51002,7 @@ ix86_expand_divmod_libfunc (rtx libfunc,
>    rtx rem = assign_386_stack_local (mode, SLOT_TEMP);
>
>    rtx quot = emit_library_call_value (libfunc, NULL_RTX, LCT_NORMAL,
> -                                     mode,
> -                                     op0, GET_MODE (op0),
> -                                     op1, GET_MODE (op1),
> +                                     mode, op0, mode, op1, mode,
>                                       XEXP (rem, 0), Pmode);
>    *quot_p = quot;
>    *rem_p = rem;
> --- gcc/testsuite/gcc.dg/pr88594.c.jj   2019-01-03 20:29:58.177819386 +0100
> +++ gcc/testsuite/gcc.dg/pr88594.c      2019-01-03 20:29:34.209213935 +0100
> @@ -0,0 +1,16 @@
> +/* PR target/88594 */
> +/* { dg-do compile { target int128 } } */
> +/* { dg-options "-O2 -fno-tree-dominator-opts -fno-tree-forwprop -fno-tree-vrp" } */
> +
> +__int128
> +foo (__int128 x, __int128 *y)
> +{
> +  int a;
> +  __int128 z, r;
> +  for (a = 0; a < 17; ++a)
> +    ;
> +  z = x / a;
> +  r = x % a;
> +  *y = z;
> +  return r;
> +}
>
>         Jakub

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

end of thread, other threads:[~2019-01-04  7:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-03 23:00 [PATCH] Fix ICE in x86 DIVMOD libfunc expansion (PR target/88594) Jakub Jelinek
2019-01-04  7:21 ` Uros Bizjak

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