Recent reload_cse_regs change

Bernd Schmidt crux@pool.informatik.rwth-aachen.de
Sat Jan 23 06:27:00 GMT 1999


On Thu, 21 Jan 1999, Jeffrey A Law wrote:

>   In message <Pine.GSO.4.02A.9901212205180.29790-100000@jennifer.informatik.rwt
> h-aachen.de>you write:
>   > Asm statements should be handled just fine by reload_cse_simplify_operands.
>   > ASM_INPUTs will cause it to exit early, as extract_insn sets
>   > recog_n_operands to 0 for them.  So if the recognition fails it's most
>   > likely a sign that some asm was mishandled by reload.
> Not handy..
> 
> You might check the testcase mentioned in this message:
> 
> http://www.cygnus.com/ml/egcs-bugs/1999-Jan/0268.html
> 
Thanks, that appears to be the right one.  I managed to strip down the
testcase a bit:

void initMasks (void * rmask, void * wmask)
{

    do {
	int __d0, __d1;
	__asm__ __volatile__ ("cld ; rep ; stosl"
			      :"=m" (*(int *) (rmask)), "=&c" (__d0), "=&D" (__d1)
			      :"a" (0), "1" ((1024 / (8 * sizeof (unsigned long)))), "2" ((int *) (rmask))
			      :"memory");
    } while (0);
    do {
	int __d0, __d1;
	__asm__ __volatile__ ("cld ; rep ; stosl"
			      :"=m" (*(int *) (wmask)), "=&c" (__d0), "=&D" (__d1)
			      :"a" (0), "1" ((1024 / (8 * sizeof (unsigned long)))), "2" ((int *) (wmask))
			      :"memory");
    } while (0);
}

The problem occurs when reloading this insn:

(insn 20 19 23 (parallel[
            (set (mem:SI (reg/v:SI 22) 2)
                (asm_operands/v ("cld ; rep ; stosl") ("=m") 0[
                        (reg:SI 1 %edx)
                        (reg:SI 27)
                        (reg/v:SI 22)
                    ]
                    [
                        (asm_input:SI ("a"))
                        (asm_input:SI ("1"))
                        (asm_input:SI ("2"))
                    ]  ("tst1.i") 10))
            (set (reg/v:SI 3 %ebx)
                (asm_operands/v ("cld ; rep ; stosl") ("=&c") 1[
                        (reg:SI 1 %edx)
                        (reg:SI 27)
                        (reg/v:SI 22)
                    ]
                    [
                        (asm_input:SI ("a"))
                        (asm_input:SI ("1"))
                        (asm_input:SI ("2"))
                    ]  ("tst1.i") 10))
            (set (reg/v:SI 4 %esi)
                (asm_operands/v ("cld ; rep ; stosl") ("=&D") 2[
                        (reg:SI 1 %edx)
                        (reg:SI 27)
                        (reg/v:SI 22)
                    ]
                    [
                        (asm_input:SI ("a"))
                        (asm_input:SI ("1"))
                        (asm_input:SI ("2"))
                    ]  ("tst1.i") 10))
            (clobber (mem:BLK (scratch) 0))
        ] ) -1 (insn_list 4 (insn_list 17 (insn_list 19 (nil))))
    (expr_list:REG_DEAD (reg/v:SI 22)
        (expr_list:REG_UNUSED (reg/v:SI 3 %ebx)
            (expr_list:REG_UNUSED (reg/v:SI 4 %esi)
                (nil)))))

First, an input reload for (reg:SI 22) is pushed, for the occurrence in the
address of the MEM in the first set.  Later, a second reload is pushed with
in == (reg:SI 22), out == (reg:SI 4 esi), for the third set.  The output
operand is an earlyclobber, but push_reload combines the two reloads
nevertheless, which causes the insn to become invalid after reloading:

(insn 20 74 23 (parallel[
            (set (mem:SI (reg:SI 5 %edi) 2)
                (asm_operands/v ("cld ; rep ; stosl") ("=m") 0[
                        (reg:SI 0 %eax)
                        (reg:SI 2 %ecx)
                        (reg:SI 5 %edi)
                    ]
                    [
                        (asm_input:SI ("a"))
                        (asm_input:SI ("1"))
                        (asm_input:SI ("2"))
                    ]  ("tst1.i") 10))
            (set (reg:SI 2 %ecx)
                (asm_operands/v ("cld ; rep ; stosl") ("=&c") 1[
                        (reg:SI 0 %eax)
                        (reg:SI 2 %ecx)
                        (reg:SI 5 %edi)
                    ]
                    [
                        (asm_input:SI ("a"))
                        (asm_input:SI ("1"))
                        (asm_input:SI ("2"))
                    ]  ("tst1.i") 10))
            (set (reg:SI 5 %edi)
                (asm_operands/v ("cld ; rep ; stosl") ("=&D") 2[
                        (reg:SI 0 %eax)
                        (reg:SI 2 %ecx)
                        (reg:SI 5 %edi)
                    ]
                    [
                        (asm_input:SI ("a"))
                        (asm_input:SI ("1"))
                        (asm_input:SI ("2"))
                    ]  ("tst1.i") 10))
            (clobber (mem:BLK (scratch) 0))
        ] ) -1 (insn_list 4 (insn_list 17 (insn_list 19 (nil))))
    (expr_list:REG_DEAD (reg/v:SI 22)
        (expr_list:REG_UNUSED (reg:SI 2 %ecx)
            (expr_list:REG_UNUSED (reg:SI 5 %edi)
                (nil)))))

Here, the earlyclobbered reg edi is used in the address of one of the
inputs.  This causes the compiler to blow up later when it calls
constrain_operands for this insn.

I suggest the following patch.  Similar code already exists in
combine_reloads.

Bernd

        * reload1.c (reload_cse_regs_1): Undo Jan 16 patch.
	* reload.c (find_reusable_reload): New function, broken out of
	push_reload.  Add code to verify that none of the involved
	outputs are subject to earlyclobbers.
	(push_reload): Break out new function find_reusable_reload.
	Delete "register" keyword for IN, OUT args.

begin 644 ecbug.diff.gz
M'XL("/Z]J38``V5C8G5G+F1I9F8`W5E;<^+&$GZ&RH]HOVQ@05[C==EK.TF%
MK#D;G_(:"MA*3J52*B$&F+*8H7190C;Y[^GN&5T`81/LAYSP@(2FI^_]3;=P
M'`>.WX0BT-ZX=>P?ZU!.G59EX,7P7T_!Z5LXN;PZ>WMU>@FMR\O+:J/1*-)O
M$YZ=&L+OOP?GW?EEJWD!#7O%1V:CZT?"#<4T<EM0F\@PBNM5J$(%0$Z@YNM$
MQ?`=G-3Y$8"W6`0KUY]Y:BK<::B3!=3JUU4'%T40"=[D17-7Z84(/36.H-9K
M#X>=_CW4I(I4O0[?$+>&W6#9%G2)Y'P1R,G*S3GPQFM+RI<UW7T=CMU(Q%`;
MZ?&J"?2-Y&SUQ=D[MMI<_R^M9N(WK^%.ZP>(9RA].L.K@%Z[W[Z[Z]P!TH-Q
M`S__[`6)B&`DI)I6G4)2E>94Z_2J=7)U=KZ=4^LIA71O3Z_H)DVIMZV+YCDT
MZ/*.7!O%7BQ]D.B[11+-7,.E4NGUN\-NK1;&OS6!OM`@_(#Y('6S\"54,D_]
M$J\6HDX>L(P_:SE..2\"SQ=SH>("=WA=9#+W_)E4PIWK\3877\]'M&@D12D3
M6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