aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@gcc.gnu.org>2003-09-10 12:59:36 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2003-09-10 12:59:36 +0000
commit1c8b4e29cc037130c30a057b0f2b8e92d933276b (patch)
tree966345a8cc85f4aa5a78833b202355d5d1d86690 /gcc
parent80e46d778a7038aaed9b5bdee838cf5dca279d7e (diff)
downloadgcc-1c8b4e29cc037130c30a057b0f2b8e92d933276b.zip
gcc-1c8b4e29cc037130c30a057b0f2b8e92d933276b.tar.gz
gcc-1c8b4e29cc037130c30a057b0f2b8e92d933276b.tar.bz2
re PR target/11965 (invalid assembler code for a shift << 32 operation)
PR target/11965 * config/sparc/sparc.c (sparc_v8plus_shift): Protect against constants greater than 63. * config/sparc/sparc.md (ashlsi3, ashrsi3, lshrsi3): Protect against constants greater than 31. (*ashldi3_sp64, *ashrdi3_sp64, *lshrdi3_sp64): Protect against constants greater than 63. From-SVN: r71266
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/config/sparc/sparc.c4
-rw-r--r--gcc/config/sparc/sparc.md33
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.dg/ultrasp10.c25
5 files changed, 69 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2b099c1..bac59f1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2003-09-10 Martin Husemann <martin@duskware.de>
+
+ PR target/11965
+ * config/sparc/sparc.c (sparc_v8plus_shift): Protect against
+ constants greater than 63.
+ * config/sparc/sparc.md (ashlsi3, ashrsi3, lshrsi3): Protect
+ against constants greater than 31.
+ (*ashldi3_sp64, *ashrdi3_sp64, *lshrdi3_sp64): Protect against
+ constants greater than 63.
+
2003-09-09 Richard Henderson <rth@redhat.com>
* cgraphunit.c (cgraph_finalize_function): Remove unused argument.
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 9e651365..4c4ea63 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -8302,6 +8302,10 @@ sparc_v8plus_shift (rtx *operands, rtx insn, const char *opcode)
if (which_alternative != 2)
operands[3] = operands[0];
+ /* We can only shift by constants <= 63. */
+ if (GET_CODE (operands[2]) == CONST_INT)
+ operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
+
if (GET_CODE (operands[1]) == CONST_INT)
{
output_asm_insn ("mov\t%1, %3", operands);
diff --git a/gcc/config/sparc/sparc.md b/gcc/config/sparc/sparc.md
index 954e89d..a987041 100644
--- a/gcc/config/sparc/sparc.md
+++ b/gcc/config/sparc/sparc.md
@@ -6908,6 +6908,8 @@
{
if (operands[2] == const1_rtx)
return "add\t%1, %1, %0";
+ if (GET_CODE (operands[2]) == CONST_INT)
+ operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
return "sll\t%1, %2, %0";
}
[(set (attr "type")
@@ -6937,6 +6939,8 @@
{
if (operands[2] == const1_rtx)
return "add\t%1, %1, %0";
+ if (GET_CODE (operands[2]) == CONST_INT)
+ operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
return "sllx\t%1, %2, %0";
}
[(set (attr "type")
@@ -6996,7 +7000,11 @@
(ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
(match_operand:SI 2 "arith_operand" "rI")))]
""
- "sra\t%1, %2, %0"
+ {
+ if (GET_CODE (operands[2]) == CONST_INT)
+ operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
+ return "sra\t%1, %2, %0";
+ }
[(set_attr "type" "shift")])
(define_insn "*ashrsi3_extend"
@@ -7043,12 +7051,17 @@
}
})
-(define_insn ""
+(define_insn "*ashrdi3_sp64"
[(set (match_operand:DI 0 "register_operand" "=r")
(ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
(match_operand:SI 2 "arith_operand" "rI")))]
"TARGET_ARCH64"
- "srax\t%1, %2, %0"
+
+ {
+ if (GET_CODE (operands[2]) == CONST_INT)
+ operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
+ return "srax\t%1, %2, %0";
+ }
[(set_attr "type" "shift")])
;; XXX
@@ -7067,7 +7080,11 @@
(lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
(match_operand:SI 2 "arith_operand" "rI")))]
""
- "srl\t%1, %2, %0"
+ {
+ if (GET_CODE (operands[2]) == CONST_INT)
+ operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
+ return "srl\t%1, %2, %0";
+ }
[(set_attr "type" "shift")])
;; This handles the case where
@@ -7124,12 +7141,16 @@
}
})
-(define_insn ""
+(define_insn "*lshrdi3_sp64"
[(set (match_operand:DI 0 "register_operand" "=r")
(lshiftrt:DI (match_operand:DI 1 "register_operand" "r")
(match_operand:SI 2 "arith_operand" "rI")))]
"TARGET_ARCH64"
- "srlx\t%1, %2, %0"
+ {
+ if (GET_CODE (operands[2]) == CONST_INT)
+ operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
+ return "srlx\t%1, %2, %0";
+ }
[(set_attr "type" "shift")])
;; XXX
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 05cf7b3..db6cc0d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,6 @@
+2003-09-10 Eric Botcazou <ebotcazou@libertysurf.fr>
+
+ * gcc.dg/ultrasp10.c: New test.
2003-09-09 Devang Patel <dpatel@apple.com>
diff --git a/gcc/testsuite/gcc.dg/ultrasp10.c b/gcc/testsuite/gcc.dg/ultrasp10.c
new file mode 100644
index 0000000..ffa3229
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ultrasp10.c
@@ -0,0 +1,25 @@
+/* PR target/11965 */
+/* Originator: <jk@tools.de> */
+/* { dg-do run { target sparc*-*-* } } */
+/* { dg-options "-O -mcpu=ultrasparc" } */
+
+/* This used to fail on 32-bit Ultrasparc because GCC emitted
+ an invalid shift instruction. */
+
+
+static inline unsigned int shift(int n, unsigned int value)
+{
+ return value << n;
+}
+
+unsigned int val = 1;
+
+int main(void)
+{
+ int i;
+
+ for (i = 0; i < 4; i++)
+ val = shift(32, val);
+
+ return 0;
+}