public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-4148] Fix bogus operand predicate on iq2000
@ 2023-09-19 17:30 Jeff Law
  0 siblings, 0 replies; only message in thread
From: Jeff Law @ 2023-09-19 17:30 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:eec7c373c2de6d5806537552de5f5b2bd064c43e

commit r14-4148-geec7c373c2de6d5806537552de5f5b2bd064c43e
Author: Jeff Law <jlaw@ventanamicro.com>
Date:   Tue Sep 19 11:28:53 2023 -0600

    Fix bogus operand predicate on iq2000
    
    The iq2000-elf port regressed these tests recently:
    
    > iq2000-sim: gcc.c-torture/execute/20040703-1.c   -O2  (test for excess errors)
    > iq2000-sim: gcc.c-torture/execute/20040703-1.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  (test for excess errors)
    > iq2000-sim: gcc.c-torture/execute/20040703-1.c   -O3 -g  (test for excess errors)
    
    It turns out one of the patterns had an operand predicate that allowed REG,
    SUBREG, CONST_INT (with a limited set of CONST_INTs).  Yet the constraint only
    allowed the limited set of immediates.  This naturally triggered an LRA
    constraint failure.
    
    The fix is trivial, create an operand predicate that accurately reflects the
    kinds of operands allowed by the instruction.
    
    It turns out this was a long standing bug -- fixing the pattern resolved 55
    failing tests in the testsuite.
    
    gcc/
            * config/iq2000/predicates.md (uns_arith_constant): New predicate.
            * config/iq2000/iq2000.md (rotrsi3): Use it.

Diff:
---
 gcc/config/iq2000/iq2000.md     | 2 +-
 gcc/config/iq2000/predicates.md | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gcc/config/iq2000/iq2000.md b/gcc/config/iq2000/iq2000.md
index aaeda39ae99..f157a82ebc0 100644
--- a/gcc/config/iq2000/iq2000.md
+++ b/gcc/config/iq2000/iq2000.md
@@ -988,7 +988,7 @@
 (define_insn "rotrsi3"
   [(set (match_operand:SI 0 "register_operand" "=r")
         (rotatert:SI (match_operand:SI 1 "register_operand" "r")
-                     (match_operand:SI 2 "uns_arith_operand" "O")))]
+                     (match_operand:SI 2 "uns_arith_constant" "O")))]
   ""
   "ram %0,%1,%2,0x0,0x0"
   [(set_attr "type" "arith")])
diff --git a/gcc/config/iq2000/predicates.md b/gcc/config/iq2000/predicates.md
index 1330f7d613c..38857e17c24 100644
--- a/gcc/config/iq2000/predicates.md
+++ b/gcc/config/iq2000/predicates.md
@@ -17,6 +17,15 @@
 ;; along with GCC; see the file COPYING3.  If not see
 ;; <http://www.gnu.org/licenses/>.
 
+;; Return 1 if OP can be used as an operand where a 16-bit
+;; unsigned integer is needed.
+
+(define_predicate "uns_arith_constant"
+  (match_code "const_int")
+{
+  return SMALL_INT_UNSIGNED (op);
+})
+
 ;; Return 1 if OP can be used as an operand where a register or 16-bit
 ;; unsigned integer is needed.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-19 17:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-19 17:30 [gcc r14-4148] Fix bogus operand predicate on iq2000 Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).