Bug 117080 - [15 Regression] FAIL: gcc.target/i386/pr88531-2b.c and FAIL: gcc.target/i386/pr88531-2c.c since r15-3509-gd34cda72098867
Summary: [15 Regression] FAIL: gcc.target/i386/pr88531-2b.c and FAIL: gcc.target/i386/...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 15.0
: P3 normal
Target Milestone: 15.0
Assignee: Richard Biener
URL:
Keywords: testsuite-fail
Depends on:
Blocks: vectorizer
  Show dependency treegraph
 
Reported: 2024-10-11 00:22 UTC by H.J. Lu
Modified: 2024-10-11 13:11 UTC (History)
3 users (show)

See Also:
Host:
Target: x86-64
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-10-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2024-10-11 00:22:29 UTC
On x86-64, I got

FAIL: gcc.target/i386/pr88531-2b.c scan-assembler-times vmulps 1
FAIL: gcc.target/i386/pr88531-2c.c scan-assembler-times vmulps 1
Comment 1 Sam James 2024-10-11 00:36:02 UTC
I see it too.
Comment 3 Richard Biener 2024-10-11 11:48:54 UTC
/home/rguenther/src/gcc/gcc/testsuite/gcc.target/i386/pr88531-2a.c:15:28: optimized: loop vectorized using 32 byte vectors
/home/rguenther/src/gcc/gcc/testsuite/gcc.target/i386/pr88531-2a.c:15:28: optimized: loop vectorized using 16 byte vectors

compared to

/home/rguenther/src/gcc-14-branch/gcc/testsuite/gcc.target/i386/pr88531-2a.c:15:28: optimized: loop vectorized using 8 byte vectors

this is the known issue around the x86 cost model not being able to see
STMT_VINFO_MEMORY_ACCESS_TYPE when using SLP.  See

https://gcc.gnu.org/pipermail/gcc-patches/2024-June/653814.html

I wasn't particularly happy with that transitional change but I guess I'll pick it up now (after re-testing of course).
Comment 4 GCC Commits 2024-10-11 13:11:33 UTC
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:

https://gcc.gnu.org/g:9f74d79afbf54d0e47905de755f41d95e46f178f

commit r15-4263-g9f74d79afbf54d0e47905de755f41d95e46f178f
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Jun 6 15:52:02 2024 +0200

    tree-optimization/117080 - Add SLP_TREE_MEMORY_ACCESS_TYPE
    
    It turns out target costing code looks at STMT_VINFO_MEMORY_ACCESS_TYPE
    to identify operations from (emulated) gathers for example.  This
    doesn't work for SLP loads since we do not set STMT_VINFO_MEMORY_ACCESS_TYPE
    there as the vectorization strathegy might differ between different
    stmt uses.  It seems we got away with setting it for stores though.
    The following adds a memory_access_type field to slp_tree and sets it
    from load and store vectorization code.  All the costing doesn't record
    the SLP node (that was only done selectively for some corner case).  The
    costing is really in need of a big overhaul, the following just massages
    the two relevant ops to fix gcc.dg/target/pr88531-2[bc].c FAILs when
    switching on SLP for non-grouped stores.  In particular currently
    we either have a SLP node or a stmt_info in the cost hook but not both.
    
    So the following mitigates this, postponing a rewrite of costing to
    next stage1.  Other targets look possibly affected as well but are
    left to respective maintainers to update.
    
            PR tree-optimization/117080
            * tree-vectorizer.h (_slp_tree::memory_access_type): Add.
            (SLP_TREE_MEMORY_ACCESS_TYPE): New.
            (record_stmt_cost): Add another overload.
            * tree-vect-slp.cc (_slp_tree::_slp_tree): Initialize
            memory_access_type.
            * tree-vect-stmts.cc (vectorizable_store): Set
            SLP_TREE_MEMORY_ACCESS_TYPE.
            (vectorizable_load): Likewise.  Also record the SLP node
            when costing emulated gather offset decompose and vector
            composition.
            * config/i386/i386.cc (ix86_vector_costs::add_stmt_cost): Also
            recognize SLP emulated gather/scatter.
Comment 5 Richard Biener 2024-10-11 13:11:53 UTC
Fixed.