Skip to content
Snippets Groups Projects
  • Jakub Jelinek's avatar
    6e7088db
    i386: Fix up __builtin_ia32_b{extr{,i}_u{32,64},zhi_{s,d}i} folding [PR116287] · 6e7088db
    Jakub Jelinek authored
    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.
    6e7088db
    History
    i386: Fix up __builtin_ia32_b{extr{,i}_u{32,64},zhi_{s,d}i} folding [PR116287]
    Jakub Jelinek authored
    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.