Emit mask fma for conditional fma
Replaces FMA with masked FMA for conditional operations to prevent unexpected exceptions.
This commit changes how conditional fused multiply-add (FMA) operations are handled on i386. Previously, it used a combination of FMA and masked move instructions, which could lead to exceptions even for masked-out values. The new implementation uses masked FMA instructions directly, avoiding these unexpected exceptions and improving correctness for conditional FMA operations.
In Details
The ix86_expand_cond_fma function replaces the previous approach of emitting a regular FMA instruction followed by a masked move for conditional FMA operations. This addresses PR128221 where the prior method could compute and potentially raise exceptions for masked-out operands. The new function directly utilizes mask FMA instructions, although this may reduce opportunities for instruction merging in some scenarios, necessitating direct expansion in the new function.
- FMA
- Fused Multiply-Add, an instruction that performs multiplication and addition in a single operation, often with higher precision and performance.
- masked move
- A data movement operation that only writes to the destination if a corresponding bit in a mask register is set. This is often used to selectively update parts of a vector register.
- exception
- An event that disrupts the normal flow of program execution, typically indicating an error condition such as division by zero or invalid memory access.
- cond_fma<mode>
- A machine-dependent instruction pattern in GCC's RTL (Register Transfer Language) for conditional fused multiply-add operations on a specific data type (mode).