Skip to content
Snippets Groups Projects
Commit 42630fad authored by Jakub Jelinek's avatar Jakub Jelinek
Browse files

i386: Fix up split_double_concat [PR109109]

In my PR107627 change I've missed one important case, which causes
miscompilation of f4 and f6 in the following tests.

Combine matches there *concatsidi3_3 define_insn_and_split (as with all
other f* functions in those tests), and RA ends up with:
(insn 11 10 17 2 (set (reg:DI 0 ax [89])
        (ior:DI (ashift:DI (zero_extend:DI (mem:SI (plus:SI (mult:SI (reg:SI 0 ax [94])
                                (const_int 4 [0x4]))
                            (symbol_ref:SI ("arr") [flags 0x2]  <var_decl 0x7f4e7fe4ccf0 arr>)) [1 arr[ax_6(D)]+0 S4 A32]))
                (const_int 32 [0x20]))
            (zero_extend:DI (reg:SI 1 dx [95])))) "pr109109-6.c":24:49 681 {*concatsidi3_3}
     (nil))
split_double_concat turned that into:
        movl    arr(,%eax,4), %edx
        movl    %edx, %eax
which is incorrect, because the first instruction overrides the input
%edx value that should be put into output %eax; the two insns can't be
swapped because the MEM's address uses %eax.

The following patch fixes that case to emit
        movl    arr(,%eax,4), %eax
        xchgl   %edx, %eax
instead.

2023-03-14  Jakub Jelinek  <jakub@redhat.com>

	PR target/109109
	* config/i386/i386-expand.cc (split_double_concat): Fix splitting
	when lo is equal to dhi and hi is a MEM which uses dlo register.

	* gcc.target/i386/pr109109-1.c: New test.
	* gcc.target/i386/pr109109-2.c: New test.
parent 423d34f6
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment