i386: Fold MINP/MAXP builtins respecting trapping math flag
Prevents folding of MINP/MAXP builtins when trapping math is enabled to preserve Signed-Aggregate Exceptions (SAE).
This change modifies the folding of MINP*/MAXP* built-in functions on i386. Previously, these builtins were always folded into conditional moves when optimizing, which inadvertently dropped Signed-Aggregate Exception (SAE) information. The fix ensures this folding only occurs when the flag_trapping_math is unset, preserving SAE semantics by avoiding the folding that would suppress denormal exception behavior.
In Details
The ix86_gimple_fold_builtin function in config/i386/i386.cc previously folded all-ones-mask MINP*/MAXP* builtins into conditional selection operations (a < b ? a : b). This folding incorrectly drops the {SAE} flag, which is relevant for preserving denormal exception behavior on x86. The commit adds a check for flag_trapping_math to disable this folding when it's set, ensuring that {SAE} is preserved.
- MINP*/MAXP*
- Intel intrinsic functions (e.g.,
_mm_min_ps,_mm_max_pd) that perform element-wise minimum or maximum operations on packed floating-point values. The 'P' typically indicates packed. - builtin functions
- Functions recognized and often optimized directly by the compiler, rather than being resolved as external function calls.
- folding
- An optimization where a function call or expression is replaced by a simpler, equivalent constant or operation known at compile time.
- {SAE}
- Signed-Aggregate Exception. On x86, this refers to the Denormal Exception (DE) flag, which signals when a denormalized floating-point number is encountered. Preserving this is important for specific floating-point semantics.
- flag_trapping_math
- A GCC internal flag that indicates whether floating-point operations should generate exceptions for conditions like denormal operands, division by zero, etc.