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  <ja...@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

Reply via email to