]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix bogus operand predicate on iq2000
authorJeff Law <jlaw@ventanamicro.com>
Tue, 19 Sep 2023 17:28:53 +0000 (11:28 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Tue, 19 Sep 2023 17:30:31 +0000 (11:30 -0600)
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.

gcc/config/iq2000/iq2000.md
gcc/config/iq2000/predicates.md

index aaeda39ae99fb3e5945795a834477d8300579bf8..f157a82ebc0dfcd4a34b526005efdba6aa68e3eb 100644 (file)
 (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")])
index 1330f7d613c6636ed5f580a34a1db40b94b7657d..38857e17c244ac5e7fe170ab2b50ff4cdad937ee 100644 (file)
 ;; 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.