]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rtl-optimization/117611 - ICE in simplify_shift_const_1
authorRichard Biener <rguenther@suse.de>
Mon, 3 Feb 2025 14:27:30 +0000 (15:27 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 4 Feb 2025 07:34:48 +0000 (08:34 +0100)
The following checks we have a scalar int shift mode before
enforcing it.  As AVR shows the mode can be a signed _Accum mode
as well.

PR rtl-optimization/117611
* combine.cc (simplify_shift_const_1): Bail if not
scalar int mode.

* gcc.dg/fixed-point/pr117611.c: New testcase.

gcc/combine.cc
gcc/testsuite/gcc.dg/fixed-point/pr117611.c [new file with mode: 0644]

index 90828108ba4c07db8b5bbdcde2f512ddf2622c0e..3beeb514b81746404831db00df5e1cd0cfe7a91f 100644 (file)
@@ -10635,8 +10635,10 @@ simplify_shift_const_1 (enum rtx_code code, machine_mode result_mode,
                                             outer_op, outer_const);
        }
 
-      scalar_int_mode shift_unit_mode
-       = as_a <scalar_int_mode> (GET_MODE_INNER (shift_mode));
+      scalar_int_mode shift_unit_mode;
+      if (!is_a <scalar_int_mode> (GET_MODE_INNER (shift_mode),
+                                  &shift_unit_mode))
+       return NULL_RTX;
 
       /* Handle cases where the count is greater than the size of the mode
         minus 1.  For ASHIFT, use the size minus one as the count (this can
diff --git a/gcc/testsuite/gcc.dg/fixed-point/pr117611.c b/gcc/testsuite/gcc.dg/fixed-point/pr117611.c
new file mode 100644 (file)
index 0000000..c76093f
--- /dev/null
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+_Accum acc1 (_Accum x)
+{
+    return x << 16;
+}