[Bug tree-optimization/126788] __builtin_convertvector upconvert + downconvert doesn't cancel out

"cvs-commit at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126788

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <[email protected]>:

https://gcc.gnu.org/g:465ee014cb0cf9be62f0fd3de3821c755d37f58d

commit r17-3331-g465ee014cb0cf9be62f0fd3de3821c755d37f58d
Author: Richard Biener <[email protected]>
Date:   Thu Aug 13 14:57:56 2026 +0200

    middle-end/126788 - more vector folding

    The last match.pd update for double-conversion folding didn't handle
    the case where a vector conversion would go away because
    supportable_convert_operation doesn't consider a noop conversion
    (or a sign conversion).  The following rectifies this, allowing
    a NOP_EXPR and VIEW_CONVERT_EXPR for same mode types as supportable
    conversion as we can RTL expand that just fine.

    This shows that the vectorizer routed sign-conversions through
    vectorizable_assignment but now vectorizable_conversion would
    handle it, emitting NOP_EXPRs (which is fine) instead of
    VIEW_CONVERT_EXPRs (which we declared canonical for vectors).
    This would confuse some foldings, leading to testsuite FAILs,
    so make vectorizable_conversion also prefer VIEW_CONVERT_EXPRs
    here.

            PR middle-end/126788
            * optabs-tree.cc (supportable_convert_operation): For same
            modes allow NOP_EXPR and VIEW_CONVERT_EXPR.
            * tree-ssa-forwprop.cc (simplify_vector_constructor): Avoid
            converting the vector to be used for blending into the
            result to the type of the permutation.
            * tree-vect-stmts.cc (vectorizable_conversion): Leave
            nop-conversions to vectorizable_assignment.

            * gcc.target/i386/pr126788.c: New testcase.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.