https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116287
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-13 branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:e5839cad7886c0277c111d96cc99c400f6f36b9d commit r13-9022-ge5839cad7886c0277c111d96cc99c400f6f36b9d Author: Jakub Jelinek <ja...@redhat.com> Date: Fri Aug 9 14:32:51 2024 +0200 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 <ja...@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. (cherry picked from commit 6e7088dbe3bf87108a89558ffb7df36df3469206)