Hi!

The following testcase ICEs in the combiner, because we try to optimize
HImode SUBREG of SImode LSHIFTRT with shift count 80, so width is -48,
and in the end we call smallest_mode_for_size (-48, MODE_INT) and
that function has unsigned int as first argument; most of the ports don't
have modes with 4Gbits yet.

Bootstrapped/regtested on x86_64-linux and i686-linux, pre-approved by
Segher on IRC, committed to trunk.

2016-11-25  Jakub Jelinek  <ja...@redhat.com>

        PR rtl-optimization/78527
        * combine.c (make_compound_operation_int): Ignore LSHIFTRT with
        out of bounds shift count.

        * gcc.c-torture/compile/pr78527.c: New test.

--- gcc/combine.c.jj    2016-11-25 09:49:50.000000000 +0100
+++ gcc/combine.c       2016-11-25 13:42:43.628487136 +0100
@@ -8091,6 +8091,8 @@ make_compound_operation_int (machine_mod
        if (GET_CODE (inner) == LSHIFTRT
            && CONST_INT_P (XEXP (inner, 1))
            && GET_MODE_SIZE (mode) < GET_MODE_SIZE (GET_MODE (inner))
+           && (UINTVAL (XEXP (inner, 1))
+               < GET_MODE_PRECISION (GET_MODE (inner)))
            && subreg_lowpart_p (x))
          {
            new_rtx = make_compound_operation (XEXP (inner, 0), next_code);
--- gcc/testsuite/gcc.c-torture/compile/pr78527.c.jj    2016-11-25 
13:44:53.806825477 +0100
+++ gcc/testsuite/gcc.c-torture/compile/pr78527.c       2016-11-25 
13:44:35.000000000 +0100
@@ -0,0 +1,21 @@
+/* PR rtl-optimization/78527 */
+
+unsigned a;
+short b, e;
+int *c;
+char d;
+
+int
+main ()
+{
+  int f = 80;
+  for (;;) {
+    if (f > 432)
+      *c = a;
+    while (b)
+      if (d)
+        e = -(a >> f);
+    c = &f;
+    b = e;
+  }
+}

        Jakub

Reply via email to