]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Sanitize the constant argument for rotr<mode>3
authorDragan Mladjenovic <dmladjenovic@wavecomp.com>
Wed, 13 Nov 2019 19:20:15 +0000 (19:20 +0000)
committerDragan Mladjenovic <draganm@gcc.gnu.org>
Wed, 13 Nov 2019 19:20:15 +0000 (19:20 +0000)
This was dormant for quite some time, but it started happening for me
on gcc.c-torture/compile/pr65153.c sometime after r276645 for -mabi=32 linux runs.

The pattern accepts any SMALL_OPERAND constant value while it asserts during the final
that the value is in the mode size range. I this case it happens that combine_and_move_insns
during ira makes a pattern with negative "shift count" which fails at final stage.

This simple fix just truncates the constant operand to mode size the same as shift patterns.

gcc/ChangeLog:

2019-11-13  Dragan Mladjenovic  <dmladjenovic@wavecomp.com>

Backport from mainline
* config/mips/mips.md (rotr<mode>3): Sanitize the constant argument
instead of asserting its value.

From-SVN: r278154

gcc/ChangeLog
gcc/config/mips/mips.md

index c0ef3795017fcc36ad96ebec1ef3712d61397a2d..400e02fae59f43ab9608a2090d3f1b87fce2ad67 100644 (file)
@@ -1,3 +1,9 @@
+2019-11-13  Dragan Mladjenovic  <dmladjenovic@wavecomp.com>
+
+       Backport from mainline
+       * config/mips/mips.md (rotr<mode>3): Sanitize the constant argument
+       instead of asserting its value.
+
 2019-11-11  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
index a9b0c86be07a9fb5bcacf5d396b10fe089c2c6b3..3cfb1a751e9b0296aa5563f8bdd3321f62711094 100644 (file)
   "ISA_HAS_ROR"
 {
   if (CONST_INT_P (operands[2]))
-    gcc_assert (INTVAL (operands[2]) >= 0
-               && INTVAL (operands[2]) < GET_MODE_BITSIZE (<MODE>mode));
+    operands[2] = GEN_INT (INTVAL (operands[2])
+                           & (GET_MODE_BITSIZE (<MODE>mode) - 1));
 
   return "<d>ror\t%0,%1,%2";
 }