This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[3.4/3.5 PATCH/RFA] Fix SH ICE with -O2 -fPIC (PR 15396)
- From: Kaz Kojima <kkojima at rr dot iij4u dot or dot jp>
- To: gcc-patches at gcc dot gnu dot org
- Cc: joern dot rennecke at superh dot com, aoliva at redhat dot com
- Date: Tue, 08 Jun 2004 07:58:01 +0900 (JST)
- Subject: [3.4/3.5 PATCH/RFA] Fix SH ICE with -O2 -fPIC (PR 15396)
Hi,
For SH, LABEL_REF isn't permited by general_operand in PIC case
and consttable_N insns use general_operand as checking function.
The insn like
(unspec_volatile [(label_ref 775)
(const_int 0 [0x0])] UNSPECV_CONST4)
which is generated by consttable_4 insn isn't recognized in PIC
case because of this and it causes the ICE in PR target/15396.
The attached patch fixes this. It bootstraps successfully on
3.4-branch with no regressions.
I've got a similar error which this patch gets rid of in building
glibc with current mainline + Joern's recent patches, though the
testcase in PR itself doesn't fail on mainline and mainline fails
for sh4-unknown-linux-gnu target when building libraries without
Joern's patches.
It also bootstraps with no regressions on mainline for sh4-linux
with those patches.
Regards,
kaz
--
PR target/15396
* config/sh/sh-protos.h (consttable_operand): Declare.
* config/sh/sh.c (consttable_operand): New.
* config/sh/sh.md (consttable_4): Use consttable_operand.
(consttable_8): Likewise.
diff -u3prN ORIG/gcc-3.4/gcc/config/sh/sh-protos.h LOCAL/gcc-3.4/gcc/config/sh/sh-protos.h
--- ORIG/gcc-3.4/gcc/config/sh/sh-protos.h Tue May 11 08:15:15 2004
+++ LOCAL/gcc-3.4/gcc/config/sh/sh-protos.h Sun Jun 6 10:47:02 2004
@@ -85,6 +85,7 @@ extern int logical_operand (rtx, enum ma
extern int tertiary_reload_operand (rtx, enum machine_mode);
extern int fpscr_operand (rtx, enum machine_mode);
extern int fpul_operand (rtx, enum machine_mode);
+extern int consttable_operand (rtx, enum machine_mode);
extern int commutative_float_operator (rtx, enum machine_mode);
extern int noncommutative_float_operator (rtx, enum machine_mode);
extern int reg_unused_after (rtx, rtx);
diff -u3prN ORIG/gcc-3.4/gcc/config/sh/sh.c LOCAL/gcc-3.4/gcc/config/sh/sh.c
--- ORIG/gcc-3.4/gcc/config/sh/sh.c Tue May 11 08:15:16 2004
+++ LOCAL/gcc-3.4/gcc/config/sh/sh.c Sun Jun 6 10:45:45 2004
@@ -8982,6 +8983,15 @@ cmpsi_operand (rtx op, enum machine_mode
&& GET_MODE (op) == SImode)
return 1;
return arith_operand (op, mode);
+}
+
+/* Like general_operand, but LABEL_REF and SYMBOL_REF are valid. */
+int
+consttable_operand (rtx op, enum machine_mode mode)
+{
+ if (GET_CODE (op) == LABEL_REF || GET_CODE (op) == SYMBOL_REF)
+ return 1;
+ return general_operand (op, mode);
}
static rtx emit_load_ptr (rtx, rtx);
diff -u3prN ORIG/gcc-3.4/gcc/config/sh/sh.md LOCAL/gcc-3.4/gcc/config/sh/sh.md
--- ORIG/gcc-3.4/gcc/config/sh/sh.md Tue May 11 08:15:16 2004
+++ LOCAL/gcc-3.4/gcc/config/sh/sh.md Sun Jun 6 10:48:07 2004
@@ -7906,7 +7906,7 @@ mov.l\\t1f,r0\\n\\
; 4 byte integer in line
(define_insn "consttable_4"
- [(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")
+ [(unspec_volatile [(match_operand:SI 0 "consttable_operand" "=g")
(match_operand 1 "" "")]
UNSPECV_CONST4)]
""
@@ -7922,7 +7922,7 @@ mov.l\\t1f,r0\\n\\
; 8 byte integer in line
(define_insn "consttable_8"
- [(unspec_volatile [(match_operand:SI 0 "general_operand" "=g")
+ [(unspec_volatile [(match_operand:SI 0 "consttable_operand" "=g")
(match_operand 1 "" "")]
UNSPECV_CONST8)]
""