This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH Re: Bootstrap problem on i386 when configured with CFLAGS=-Oin environment
- To: Loren James Rittle <rittle at latour dot rsch dot comm dot mot dot com>
- Subject: PATCH Re: Bootstrap problem on i386 when configured with CFLAGS=-Oin environment
- From: Alan Modra <alan at SPRI dot Levels dot UniSA dot Edu dot Au>
- Date: Sat, 5 Feb 2000 23:27:08 +1030 (CST)
- cc: gcc-patches at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, pfeifer at dbai dot tuwien dot ac dot at, Richard Henderson <rth at cygnus dot com>, Jan Hubicka <hubicka at atrey dot karlin dot mff dot cuni dot cz>
rittle@latour.rsch.comm.mot.com wrote:
> The problem is that split_insns() generates and try_split() accepts
> this:
>
> (set (reg:CCNO 17 flags)
> (compare:CCNO (and:SI (reg:SI 0 eax)
> (const_int -32767 [0xffff8001]))
> (const_int 0 [0x0])))
>
> as a valid replacement for this:
>
> (set (reg:CCNO 17 flags)
> (compare:CCNO (and:HI (reg:HI 0 ax)
> (const_int -32767 [0xffff8001]))
> (const_int 0 [0x0])))
This is another manifestation of the problem that I posted a test for at
http://gcc.gnu.org/ml/gcc-patches/2000-02/msg00105.html
The following patch ought to fix it, but current CVS gcc bombs
/usr/src/egcs/gcc/frame
xgcc: Internal compiler error: program cc1 got fatal signal 11
make[1]: *** [libgcc2.a] Error 1
#0 0x81d0eab in ix86_agi_dependant (insn=0x40375280, dep_insn=0x40375200,
insn_type=TYPE_LEA) at /usr/src/egcs/gcc/config/i386/i386.c:5952
#1 0x81d0fd8 in ix86_adjust_cost (insn=0x40375280, link=0x403766d0,
dep_insn=0x40375200, cost=1) at
/usr/src/egcs/gcc/config/i386/i386.c:6004
#2 0x8146356 in priority (insn=0x40375200)
at /usr/src/egcs/gcc/haifa-sched.c:3084
#3 0x814c9d6 in set_priorities (bb=0) at
/usr/src/egcs/gcc/haifa-sched.c:6606
#4 0x814cb17 in schedule_region (rgn=0)
at /usr/src/egcs/gcc/haifa-sched.c:6654
#5 0x814d2bf in schedule_insns (dump_file=0x0)
at /usr/src/egcs/gcc/haifa-sched.c:6948
with or without my patch, so I can't test it properly yet. I've just run
cc1 over my test file to prove that the patch does actually fix the
test case.
gcc/ChangeLog
* config/i386/i386.md (define_split compare:CCNO and): Mask high
bits of negative QI and HI constants with gen_unsigned_lowpart.
* config/i386/i386.c (gen_unsigned_lowpart): New function.
* config/i386/i386-protos.h (gen_unsigned_lowpart): Declare.
--- ./gcc/config/i386/i386.md~ Sat Feb 5 10:05:58 2000
+++ ./gcc/config/i386/i386.md Sat Feb 5 20:17:05 2000
@@ -8941,9 +8941,9 @@
(const_int 0)))
(set (match_dup 0)
(and:SI (match_dup 1) (match_dup 2)))])]
- "operands[0] = gen_lowpart (SImode, operands[0]);
- operands[1] = gen_lowpart (SImode, operands[1]);
- operands[2] = gen_lowpart (SImode, operands[2]);")
+ "operands[2] = gen_unsigned_lowpart (GET_MODE (operands[0]), operands[2]);
+ operands[0] = gen_lowpart (SImode, operands[0]);
+ operands[1] = gen_lowpart (SImode, operands[1]);")
(define_split
[(set (reg:CCNO 17)
@@ -8957,8 +8957,8 @@
[(set (reg:CCNO 17)
(compare:CCNO (and:SI (match_dup 0) (match_dup 1))
(const_int 0)))]
- "operands[0] = gen_lowpart (SImode, operands[0]);
- operands[1] = gen_lowpart (SImode, operands[1]);")
+ "operands[1] = gen_unsigned_lowpart (GET_MODE (operands[0]), operands[1]);
+ operands[0] = gen_lowpart (SImode, operands[0]);")
(define_split
[(set (match_operand 0 "register_operand" "")
--- ./gcc/config/i386/i386.c~ Sat Feb 5 10:05:58 2000
+++ ./gcc/config/i386/i386.c Sat Feb 5 20:20:48 2000
@@ -5617,6 +5617,33 @@
emit_label (end_0_label);
}
+
+struct rtx_def *
+gen_unsigned_lowpart (mode, imm)
+ enum machine_mode mode;
+ struct rtx_def *imm;
+{
+ int shift;
+ HOST_WIDE_INT oldval;
+ HOST_WIDE_INT newval;
+
+ if (GET_MODE (imm) == mode)
+ return imm;
+
+ if (GET_CODE (imm) != CONST_INT)
+ abort ();
+
+ shift = HOST_BITS_PER_WIDE_INT - GET_MODE_BITSIZE (mode);
+ oldval = INTVAL (imm);
+
+ /* Unsigned extend to HOST_WIDE_INT. */
+ newval = ((unsigned HOST_WIDE_INT) oldval << shift >> shift);
+
+ if (oldval == newval)
+ return imm;
+
+ return GEN_INT (newval);
+}
/* Clear stack slot assignments remembered from previous functions.
This is called from INIT_EXPANDERS once before RTL is emitted for each
--- ./gcc/config/i386/i386-protos.h~ Thu Feb 3 00:23:29 2000
+++ ./gcc/config/i386/i386-protos.h Sat Feb 5 20:27:24 2000
@@ -105,6 +105,7 @@
extern void ix86_split_ashrdi PARAMS ((rtx *, rtx));
extern void ix86_split_lshrdi PARAMS ((rtx *, rtx));
extern void ix86_expand_strlensi_unroll_1 PARAMS ((rtx, rtx, rtx));
+extern rtx gen_unsigned_lowpart PARAMS ((enum machine_mode, rtx));
extern rtx assign_386_stack_local PARAMS ((enum machine_mode, int));
extern int ix86_attr_length_default PARAMS ((rtx));