public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* messy combine problem - PPC
@ 2001-12-03 12:49 Zack Weinberg
  2001-12-03 15:06 ` Richard Henderson
  0 siblings, 1 reply; 7+ messages in thread
From: Zack Weinberg @ 2001-12-03 12:49 UTC (permalink / raw)
  To: gcc

I'm looking at a nasty combine problem exposed by my PPC ABI patches.
Suppose you have code like this:

struct a { 
  char hours, day, month;
  short year;
};

extern struct a A;
extern struct a ret_struct_a();

void test(void)
{
  A = ret_struct_a();
}

Right before combine, we have this RTL:

(call_insn 8 48 9 (parallel[ 
            (set (reg:DI 3 r3)
                (call (mem:SI (symbol_ref:SI ("ret_struct_a")) [0 S4 A32])
                    (const_int 0 [0x0])))
            (use (const_int 0 [0x0]))
            (clobber (scratch:SI))
        ] ) -1 (nil)
    (expr_list:REG_UNUSED (scratch:SI)
        (nil))
    (nil))

(insn 9 8 11 (set (reg:SI 115)
        (zero_extend:SI (subreg:HI (reg:SI 3 r3) 2)))
	 30 {*rs6000.md:1385}
    (insn_list 8 (nil))
    (expr_list:REG_DEAD (reg:SI 3 r3)
        (nil)))

As far as I know this is correct RTL.  Combine tries to do something
(I'm not entirely sure what) with insn 9.  At -O1, in the course of
that it calls get_last_value for

  (subreg:HI (reg:SI 3 r3) 2)

and get_last_value obligingly tries to return the call pattern wrapped
in a SUBREG.  This blows up in simplify_gen_subreg, since the call RTX
has no mode.

Breakpoint 1, fancy_abort (
    file=0x8439ba0 "../../../gcc/ppc-eabi/gcc/simplify-rtx.c", line=2649, 
    function=0x843a11b "simplify_gen_subreg")
    at ../../../gcc/ppc-eabi/gcc/diagnostic.c:1450
1450      internal_error ("Internal compiler error in %s, at %s:%d",
(gdb) bt
#0  fancy_abort (file=0x8439ba0 "../../../gcc/ppc-eabi/gcc/simplify-rtx.c", 
    line=2649, function=0x843a11b "simplify_gen_subreg")
    at ../../../gcc/ppc-eabi/gcc/diagnostic.c:1450
#1  0x082b61a9 in simplify_gen_subreg (outermode=HImode, op=0x40174df8, 
    innermode=VOIDmode, byte=0)
    at ../../../gcc/ppc-eabi/gcc/simplify-rtx.c:2649
#2  0x0834d2aa in gen_lowpart_for_combine (mode=HImode, x=0x40174df8)
    at ../../../gcc/ppc-eabi/gcc/combine.c:9748
#3  0x08351cc8 in get_last_value (x=0x4016ea20)
    at ../../../gcc/ppc-eabi/gcc/combine.c:11366


At -O2, -fexpensive-optimizations is on, and 

  (zero_extend:SI (subreg:HI (reg:SI 3 r3) 2))

is replaced by

  (and:SI (reg:SI 3 r3) (const_int 65535 [0xffff]))

before anything else happens; this goes through a different code path,
combine asks for the last value of (reg:SI 3 r3), and
simplify_gen_subreg is not asked to do anything with the CALL pattern.

The $64,000 question: what's the right fix here?  The incoming RTL is
correct, so a fix in the machine description is inappropriate.
simplify_gen_subreg is correct to abort, (subreg:HI (call ...) N) is
ill-formed.  I'm not familiar enough with combine to know where in
between these two the fix should go.

Ideas?

zw

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2001-12-04 18:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-03 12:49 messy combine problem - PPC Zack Weinberg
2001-12-03 15:06 ` Richard Henderson
2001-12-03 15:53   ` Zack Weinberg
2001-12-03 18:27     ` Richard Henderson
2001-12-03 22:34       ` Zack Weinberg
2001-12-04  9:31         ` Richard Henderson
2001-12-04 10:06           ` Zack Weinberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).