aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2024-06-21 15:40:10 +0100
committerRichard Sandiford <richard.sandiford@arm.com>2024-06-21 15:40:10 +0100
commit8f254cd4e40b692e5f01a3b40f2b5b60c8528a1e (patch)
treec9a3c4c620ef80442c0ede2c022c7c4a7ee48c28
parent4a43a06c7b2bcc3402ac69d6e5ce7b8008acc69a (diff)
downloadgcc-8f254cd4e40b692e5f01a3b40f2b5b60c8528a1e.zip
gcc-8f254cd4e40b692e5f01a3b40f2b5b60c8528a1e.tar.gz
gcc-8f254cd4e40b692e5f01a3b40f2b5b60c8528a1e.tar.bz2
iq2000: Fix test and branch instructions
The iq2000 test and branch instructions had patterns like: [(set (pc) (if_then_else (eq (and:SI (match_operand:SI 0 "register_operand" "r") (match_operand:SI 1 "power_of_2_operand" "I")) (const_int 0)) (match_operand 2 "pc_or_label_operand" "") (match_operand 3 "pc_or_label_operand" "")))] power_of_2_operand allows any 32-bit power of 2, whereas "I" only accepts 16-bit signed constants. This meant that any power of 2 greater than 32768 would cause an "insn does not satisfy its constraints" ICE. Also, the %p operand modifier barfed on 1<<31, which is sign- rather than zero-extended to 64 bits. The code is inherently limited to 32-bit operands -- power_of_2_operand contains a test involving "unsigned" -- so this patch just ands with 0xffffffff. gcc/ * config/iq2000/iq2000.cc (iq2000_print_operand): Make %p handle 1<<31. * config/iq2000/iq2000.md: Remove "I" constraints on power_of_2_operands.
-rw-r--r--gcc/config/iq2000/iq2000.cc2
-rw-r--r--gcc/config/iq2000/iq2000.md4
2 files changed, 3 insertions, 3 deletions
diff --git a/gcc/config/iq2000/iq2000.cc b/gcc/config/iq2000/iq2000.cc
index f9f8c41..136675d 100644
--- a/gcc/config/iq2000/iq2000.cc
+++ b/gcc/config/iq2000/iq2000.cc
@@ -3127,7 +3127,7 @@ iq2000_print_operand (FILE *file, rtx op, int letter)
{
int value;
if (code != CONST_INT
- || (value = exact_log2 (INTVAL (op))) < 0)
+ || (value = exact_log2 (UINTVAL (op) & 0xffffffff)) < 0)
output_operand_lossage ("invalid %%p value");
else
fprintf (file, "%d", value);
diff --git a/gcc/config/iq2000/iq2000.md b/gcc/config/iq2000/iq2000.md
index 8617efa..e62c250 100644
--- a/gcc/config/iq2000/iq2000.md
+++ b/gcc/config/iq2000/iq2000.md
@@ -1175,7 +1175,7 @@
[(set (pc)
(if_then_else
(eq (and:SI (match_operand:SI 0 "register_operand" "r")
- (match_operand:SI 1 "power_of_2_operand" "I"))
+ (match_operand:SI 1 "power_of_2_operand"))
(const_int 0))
(match_operand 2 "pc_or_label_operand" "")
(match_operand 3 "pc_or_label_operand" "")))]
@@ -1189,7 +1189,7 @@
[(set (pc)
(if_then_else
(ne (and:SI (match_operand:SI 0 "register_operand" "r")
- (match_operand:SI 1 "power_of_2_operand" "I"))
+ (match_operand:SI 1 "power_of_2_operand"))
(const_int 0))
(match_operand 2 "pc_or_label_operand" "")
(match_operand 3 "pc_or_label_operand" "")))]