This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
virtual-stack-vars reference not resolved in vregs
- From: Paul Koning <paulkoning at comcast dot net>
- To: GCC Development <gcc at gcc dot gnu dot org>
- Date: Thu, 24 May 2018 20:35:31 -0400
- Subject: virtual-stack-vars reference not resolved in vregs
I'm doing cleanup on the pdp11 back end to get rid of a
number of ICE in the test suite. One is in
gcc.c-torture/compile/20001221.c -- it works in GCC 4 but
fails in GCC 5 and later.
In the dumps, I see in the output from the expand phase a
large number of memory reference via the "virtual-stack-vars"
pseudo-register. In vregs those all become frame pointer
references in V4, but in V5 and later, about 10% of them
remain pseudo-register references all the way through final
assembly output generation. There things blow up because
it's an invalid base register.
Here are some snippets:
static void
foo ()
{
long maplength;
int type;
{
const long nibbles = 8;
char buf1[nibbles + 1];
...
V4, expand output:
;; nibbles_18 = 8;
(insn 7 6 0 (set (mem/c:SI (plus:HI (reg/f:HI 17 virtual-stack-vars)
(const_int -8 [0xfffffffffffffff8])) [0 nibbles+0 S4 A16])
(const_int 8 [0x8])) /Users/pkoning/Documents/svn/gcc/gcc/testsuite/gcc.c-torture/compile/20001221-1.c:8 -1
(nil))
;; _19 = (sizetype) nibbles_18;
(insn 8 7 0 (set (mem/c:HI (plus:HI (reg/f:HI 17 virtual-stack-vars)
(const_int -10 [0xfffffffffffffff6])) [0 D.1480+0 S2 A16])
(subreg:HI (mem/c:SI (plus:HI (reg/f:HI 17 virtual-stack-vars)
(const_int -8 [0xfffffffffffffff8])) [0 nibbles+0 S4 A16]) 0)) /Users/pkoning/Documents/svn/gcc/gcc/testsuite/gcc.c-torture/compile/20001221-1.c:9 -1
(nil))
The second insn is picking up the low order half of "nibbles"
to use as the index; note that Pmode is HI for this target.
The vregs pass turns it into this:
(insn 7 6 8 2 (set (mem/c:SI (plus:HI (reg/f:HI 14 fp)
(const_int -8 [0xfffffffffffffff8])) [0 nibbles+0 S4 A16])
(const_int 8 [0x8])) /Users/pkoning/Documents/svn/gcc/gcc/testsuite/gcc.c-torture/compile/20001221-1.c:8 12 {movsi}
(nil))
(insn 8 7 9 2 (set (mem/c:HI (plus:HI (reg/f:HI 14 fp)
(const_int -10 [0xfffffffffffffff6])) [0 D.1480+0 S2 A16])
(subreg:HI (mem/c:SI (plus:HI (reg/f:HI 17 virtual-stack-vars)
(const_int -8 [0xfffffffffffffff8])) [0 nibbles+0 S4 A16]) 0)) /Users/pkoning/Documents/svn/gcc/gcc/testsuite/gcc.c-torture/compile/20001221-1.c:9 14 {movhi}
(nil))
which is what I would expect.
In V5, the expand output is the same:
(insn 7 6 0 (set (mem/c:SI (plus:HI (reg/f:HI 17 virtual-stack-vars)
(const_int -8 [0xfffffffffffffff8])) [0 nibbles+0 S4 A16])
(const_int 8 [0x8])) /Users/pkoning/Documents/svn/gcc/gcc/testsuite/gcc.c-torture/compile/20001221-1.c:8 -1
(nil))
;; _19 = (sizetype) nibbles_18;
(insn 8 7 0 (set (mem/c:HI (plus:HI (reg/f:HI 17 virtual-stack-vars)
(const_int -10 [0xfffffffffffffff6])) [0 D.1480+0 S2 A16])
(subreg:HI (mem/c:SI (plus:HI (reg/f:HI 17 virtual-stack-vars)
(const_int -8 [0xfffffffffffffff8])) [0 nibbles+0 S4 A16]) 0)) /Users/pkoning/Documents/svn/gcc/gcc/testsuite/gcc.c-torture/compile/20001221-1.c:9 -1
(nil))
but now vregs doesn't convert the virtual-stack-vars reference
in the subreg operand:
(insn 7 6 8 2 (set (mem/c:SI (plus:HI (reg/f:HI 14 fp)
(const_int -8 [0xfffffffffffffff8])) [0 nibbles+0 S4 A16])
(const_int 8 [0x8])) /Users/pkoning/Documents/svn/gcc/gcc/testsuite/gcc.c-torture/compile/20001221-1.c:8 12 {movsi}
(nil))
(insn 8 7 9 2 (set (mem/c:HI (plus:HI (reg/f:HI 14 fp)
(const_int -10 [0xfffffffffffffff6])) [0 D.1480+0 S2 A16])
(subreg:HI (mem/c:SI (plus:HI (reg/f:HI 17 virtual-stack-vars)
(const_int -8 [0xfffffffffffffff8])) [0 nibbles+0 S4 A16]) 0)) /Users/pkoning/Documents/svn/gcc/gcc/testsuite/gcc.c-torture/compile/20001221-1.c:9 14 {movhi}
(nil))
Is this something the back end is responsible for getting right, for example
via the machine description file? If so, any hints where to start?
paul