https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102224
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org Status|NEW |ASSIGNED --- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 51422 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51422&action=edit gcc12-pr102224.patch Untested fix. It is actually a mess. While we can during expansion emit efficient fabs code if the two input operands are equal, we still need to ensure correctness for the case where the operand equality is discovered only after expansion. This patch does that by ensuring through early-clobber and constraints that for pre-AVX dest==op1 is different from op0, because we want to overwrite op1 first with op1 & mask before using op0. For AVX, the constraints ensure that either all of dest, op0 and op1 are different, or any two of them are the same but the third one is different. If op0 and op1 are different, then it is ok without further changes, the i386-expand.c changes are for the op0 == op1 case where we've ensured that dest is different from the inputs - we can emit vpandn but if the mask is in memory, we need to force it into a register and can use dest for that.