From: Zack Weinberg <zack@codesourcery.com>
To: gcc@gcc.gnu.org
Subject: messy combine problem - PPC
Date: Mon, 03 Dec 2001 12:49:00 -0000 [thread overview]
Message-ID: <20011203204934.GG292@codesourcery.com> (raw)
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
next reply other threads:[~2001-12-03 20:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-03 12:49 Zack Weinberg [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20011203204934.GG292@codesourcery.com \
--to=zack@codesourcery.com \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).