This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] [MIPS] Sanitize the constant argument for rotr<mode>3
- From: Dragan Mladjenovic <dmladjenovic at wavecomp dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Cc: Dragan Mladjenovic <dmladjenovic at wavecomp dot com>, Jeff Law <law at redhat dot com>, Matthew Fortune <mfortune at gmail dot com>
- Date: Tue, 12 Nov 2019 14:56:18 +0000
- Subject: [PATCH] [MIPS] Sanitize the constant argument for rotr<mode>3
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wavecomp.com; dmarc=pass action=none header.from=wavecomp.com; dkim=pass header.d=wavecomp.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OOkHAZAAO79kJvpJQCsORUlGKVyu5aJll/blSFPC3+c=; b=YHYPRFKwpO67sWjYoGmUZVhMZv4+Ia7j2QsJ4xxqXSIlgyJSsJG3L1hOuK4LurCHqLTbl/twTsV/YKat2JIzm/yBU8MeXGRwzX1pVf4I32SyLjfOokoaUxiyPIaLkarfEZ8/mdRFayTEmpcPcoaEmDtbR4xLUAkvcFlxJSihzrDYj0R/ciPPOyCkSXWbYP2xtVI55uHF6Vh3F40lEROaC6yAVTzDTaJ5R9mq135ocFnDakdBbOdNyEjanBQukZMHSpxkm7vNyS8V7dhpIagYYoxYX/tfV7QrEfcJmdASSPIJxMvz56ShEgObkctJ3P69SUMQtut8ZuZHk6vvmAcfWQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dqVJ61pLQUYfaLiMshkItR8Vp5LpPQmJR+5+A9HdyMc/yaDBdi7120rJUTJLAnURosLE1atT2RlXkAv/3aF5A42G/ksU9DnfJ6eSmyGVokaslBh5nYHupOg3vi7yzPMklz2fFzH/4XqIzzIzTHCB1QGpabMNVMNi35BCxxLwyYZU7fCmG/G6EvUdKRYFuR8poVZB83tc/IJy9f57/oKu3HNKALrNX1krtLNrfL7e3jVxhHdoKg35+IPtr0Q+mxmLhwU2IIavsIJ0PfIJmTub+lWsku3BZO/KwmkngdwNoOcCePM5qyjMSC9MwbVNI03NQJsFx6cZCxc+XAtEWLvmtg==
From: "Dragan Mladjenovic" <dmladjenovic@wavecomp.com>
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-12 Dragan Mladjenovic <dmladjenovic@wavecomp.com>
* config/mips/mips.md (rotr<mode>3): Sanitize the constant argument
instead of asserting its value.
---
Ok, for trunk and backport to gcc 9 and 8 branches?
gcc/config/mips/mips.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md
index 658f5e6..1d63aca 100644
--- a/gcc/config/mips/mips.md
+++ b/gcc/config/mips/mips.md
@@ -5845,8 +5845,8 @@
"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";
}
--
1.9.1