Bug 83009 - gcc.target/aarch64/store_v2vec_lanes.c fails with -mabi=ilp32
Summary: gcc.target/aarch64/store_v2vec_lanes.c fails with -mabi=ilp32
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: 9.0
Assignee: avieira
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2017-11-15 16:27 UTC by Christophe Lyon
Modified: 2018-07-19 14:03 UTC (History)
0 users

See Also:
Host:
Target: aarch64
Build:
Known to work:
Known to fail: 8.0
Last reconfirmed: 2017-11-15 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christophe Lyon 2017-11-15 16:27:56 UTC
Hi,

As reported in https://gcc.gnu.org/ml/gcc-patches/2017-11/msg01213.html ,
the new gcc.target/aarch64/store_v2vec_lanes.c fails when using -abi=ilp32.

Kyrill said:
My patch does indeed fail to generate the optimised sequence for -mabi=ilp32.
During combine it fails to match:
Failed to match this instruction:
(set (mem:V2DF (plus:DI (reg/v/f:DI 79 [ z ])
            (const_int 32 [0x20])) [1 MEM[(v2df *)z_8(D) + 32B]+0 S16 A128])
    (vec_concat:V2DF (reg:DF 81 [ y0 ])
        (reg:DF 84 [ y1 ])))


but without the -mabi=ilp32 it does successfully match the equivalent

(set (mem:V2DF (plus:DI (reg:DI 1 x1 [ z ])
            (const_int 32 [0x20])) [1 MEM[(v2df *)z_8(D) + 32B]+0 S16 A128])
    (vec_concat:V2DF (reg:DF 81 [ y0 ])
        (reg:DF 84 [ y1 ])))

The only difference is the index register being the hard reg x1.
There's probably some subtlety in aarch64_classify_address that I'll need to dig into.
Comment 1 ktkachov 2017-11-15 16:29:57 UTC
Thanks, confirmed.
Comment 2 Richard Biener 2018-03-27 09:38:57 UTC
New test so the regression is a testsuite issue (should be XFAILed for ilp32).  Please do so ASAP, then we can drop the regression marker.  Improving code-gen on ilp32 is an enhancement.
Comment 3 ktkachov 2018-03-27 16:52:42 UTC
Author: ktkachov
Date: Tue Mar 27 16:52:10 2018
New Revision: 258894

URL: https://gcc.gnu.org/viewcvs?rev=258894&root=gcc&view=rev
Log:
[AArch64] XFAIL gcc.target/aarch64/store_v2vec_lanes.c for ILP32

The test in question fails for ilp32. The initial analysis I did in the PR for it
is that for ILP32 we generate somewhat different address forms that we'd need to adjust aarch64_classify_address to catch.
Given the optimisation this test checks for was added for GCC 8 it is not a regression, and improving the codegen on ILP32
would be an enhancement rather than a fix. So Richi has asked for it to be marked as XFAIL on ILP32, which is what this
patch does.
Checked that the test still passes on LP64 and appears as XFAIL on -mabi=ilp32.

	PR target/83009
	* gcc.target/aarch64/store_v2vec_lanes.c: XFAIL for ilp32.

Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.target/aarch64/store_v2vec_lanes.c
Comment 4 ktkachov 2018-03-27 16:54:26 UTC
Test is XFAILed.
Codegen improvement for ILP32 is not a blocker for GCC 8
Comment 5 avieira 2018-04-11 14:49:27 UTC
I have been looking at this and the problem does indeed lie with the register not being a hard reg because aarch64_mem_pair_lanes_operand invokes aarch64_legitimate_address_p with 1 for the strict_p argument.

Changing that to a 0 yields the desired results for this testcase. Also good to note that this is not an ilp32 issue only, because of this we would also miss cases where the argument hard-register would not be successfully combined into the load/store. Say if for instance the argument in the test function were a pointer to the pointer we are addressing.

I will proceed to run tests now, if someone knows why that "strict_p" was being set to 1  please let me know, I am unfamiliar with this code and fear this might be too big a hammer.
Comment 6 ktkachov 2018-04-11 14:57:08 UTC
(In reply to avieira from comment #5)
> I have been looking at this and the problem does indeed lie with the
> register not being a hard reg because aarch64_mem_pair_lanes_operand invokes
> aarch64_legitimate_address_p with 1 for the strict_p argument.
> 
> Changing that to a 0 yields the desired results for this testcase. Also good
> to note that this is not an ilp32 issue only, because of this we would also
> miss cases where the argument hard-register would not be successfully
> combined into the load/store. Say if for instance the argument in the test
> function were a pointer to the pointer we are addressing.
> 
> I will proceed to run tests now, if someone knows why that "strict_p" was
> being set to 1  please let me know, I am unfamiliar with this code and fear
> this might be too big a hammer.

I think requiring strict address checking in aarch64_mem_pair_lanes_operand is overly conservative indeed. The store_pair_lanes<mode> pattern that uses it is supposed to be created at combine-time at which point we want to allow any type of register. Then during reg-alloc the Uml constraint enforces the strict checking.

So I think relaxing aarch64_mem_pair_lanes_operand is the right way forward, though of course testing will show.
Comment 7 avieira 2018-04-16 09:37:50 UTC
Bootstrap and regression testing looks good. Ill put the patch up on the ML when we enter stage 1 again.
Comment 8 avieira 2018-05-24 08:54:12 UTC
Author: avieira
Date: Thu May 24 08:53:39 2018
New Revision: 260635

URL: https://gcc.gnu.org/viewcvs?rev=260635&root=gcc&view=rev
Log:
PR target/83009: Relax strict address checking for store pair lanes

The operand constraint for the memory address of store/load pair lanes was
enforcing strictly hardware registers be allowed as memory addresses.  We want
to relax that such that these patterns can be used by combine.  During register
allocation the register constraint will enforce the correct register is chosen.

gcc
2018-05-24  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	PR target/83009
	* config/aarch64/predicates.md (aarch64_mem_pair_lanes_operand): Make
	address check not strict.

gcc/testsuite
2018-05-24  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	PR target/83009
	* gcc/target/aarch64/store_v2vec_lanes.c: Add extra tests.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/aarch64/predicates.md
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.target/aarch64/store_v2vec_lanes.c
Comment 9 avieira 2018-05-29 11:06:46 UTC
I believe my patch fixes this.
Comment 10 avieira 2018-05-30 15:59:48 UTC
Author: avieira
Date: Wed May 30 15:59:14 2018
New Revision: 260957

URL: https://gcc.gnu.org/viewcvs?rev=260957&root=gcc&view=rev
Log:
Reverting r260635

    gcc
    2018-05-30  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	2018-05-24  Andre Vieira  <andre.simoesdiasvieira@arm.com>

        PR target/83009
	Revert:
        * config/aarch64/predicates.md (aarch64_mem_pair_lanes_operand): Make
        address check not strict.

    gcc/testsuite
    2018-05-30  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	2018-05-24  Andre Vieira  <andre.simoesdiasvieira@arm.com>
	Revert
        PR target/83009
        * gcc/target/aarch64/store_v2vec_lanes.c: Add extra tests.
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@260635 138bc75d-0d04-0410-961f-82ee72b054a4

Modified:
    trunk/gcc/config/aarch64/predicates.md
    trunk/gcc/testsuite/gcc.target/aarch64/store_v2vec_lanes.c
Comment 11 avieira 2018-07-19 14:03:52 UTC
Author: avieira
Date: Thu Jul 19 14:03:21 2018
New Revision: 262881

URL: https://gcc.gnu.org/viewcvs?rev=262881&root=gcc&view=rev
Log:
[AArch64][PATCH 2/2] PR target/83009: Relax strict address checking for store
pair lanes

gcc/ChangeLog
2018-07-19  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	PR target/83009
	* config/aarch64/predicates.md (aarch64_mem_pair_lanes_operand): Make
	address check not strict.

gcc/testsuite/ChangeLog
2018-07-19  Andre Vieira  <andre.simoesdiasvieira@arm.com>

	PR target/83009
	* gcc/target/aarch64/store_v2vec_lanes.c: Add extra tests.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/aarch64/predicates.md
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.target/aarch64/store_v2vec_lanes.c