]> git.ipfire.org Git - thirdparty/gcc.git/commit
i386: Fix up __builtin_ia32_b{extr{,i}_u{32,64},zhi_{s,d}i} folding [PR116287]
authorJakub Jelinek <jakub@redhat.com>
Fri, 9 Aug 2024 12:32:51 +0000 (14:32 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 9 Aug 2024 12:32:51 +0000 (14:32 +0200)
commit6e7088dbe3bf87108a89558ffb7df36df3469206
tree2b04ffae04a128d372d6c33a3406d9132d351ea7
parentb5a09a68bf0feaf0b0678d8f3433f776238d3896
i386: Fix up __builtin_ia32_b{extr{,i}_u{32,64},zhi_{s,d}i} folding [PR116287]

The GENERIC folding of these builtins have cases where it folds to a
constant regardless of the value of the first operand.  If so, we need
to use omit_one_operand to avoid throwing away side-effects in the first
operand if any.  The cases which verify the first argument is INTEGER_CST
don't need that, INTEGER_CST doesn't have side-effects.

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

PR target/116287
* config/i386/i386.cc (ix86_fold_builtin) <case IX86_BUILTIN_BEXTR32>:
When folding into zero without checking whether first argument is
constant, use omit_one_operand.
(ix86_fold_builtin) <case IX86_BUILTIN_BZHI32>: Likewise.

* gcc.target/i386/bmi-pr116287.c: New test.
* gcc.target/i386/bmi2-pr116287.c: New test.
* gcc.target/i386/tbm-pr116287.c: New test.
gcc/config/i386/i386.cc
gcc/testsuite/gcc.target/i386/bmi-pr116287.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/bmi2-pr116287.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/tbm-pr116287.c [new file with mode: 0644]