]> git.ipfire.org Git - thirdparty/gcc.git/commit
i386: Add GENERIC and GIMPLE folders of __builtin_ia32_{min,max}* [PR116738]
authorJakub Jelinek <jakub@redhat.com>
Wed, 25 Sep 2024 18:17:11 +0000 (20:17 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 25 Sep 2024 18:19:28 +0000 (20:19 +0200)
commitcc40795d8956d78e719a6acc83d5abad7032a6c3
tree279e4ffa8ed01fbb78caf5d1dc345b7babd5afb1
parentc79cc30862d7255ca15884aa956d1ccfa279d86a
i386: Add GENERIC and GIMPLE folders of __builtin_ia32_{min,max}* [PR116738]

The following patch adds GENERIC and GIMPLE folders for various
x86 min/max builtins.
As discussed, these builtins have effectively x < y ? x : y
(or x > y ? x : y) behavior.
The GENERIC folding is done if all the (relevant) arguments are
constants (such as VECTOR_CST for vectors) and is done because
the GIMPLE folding can't easily handle masking, rounding and the
ss/sd cases (in a way that it would be pattern recognized back to the
corresponding instructions).  The GIMPLE folding is also done just
for TARGET_SSE4 or later when optimizing, otherwise it is apparently
not matched back.

2024-09-25  Jakub Jelinek  <jakub@redhat.com>

PR target/116738
* config/i386/i386.cc (ix86_fold_builtin): Handle
IX86_BUILTIN_M{IN,AX}{S,P}{S,H,D}*.
(ix86_gimple_fold_builtin): Handle IX86_BUILTIN_M{IN,AX}P{S,H,D}*.

* gcc.target/i386/avx512f-pr116738-1.c: New test.
* gcc.target/i386/avx512f-pr116738-2.c: New test.
gcc/config/i386/i386.cc
gcc/testsuite/gcc.target/i386/avx512f-pr116738-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-pr116738-2.c [new file with mode: 0644]