https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108571
Bug ID: 108571 Summary: Fix for PR96373 regresses fabd_1.c with -ftrapping-math Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rsandifo at gcc dot gnu.org Target Milestone: --- Target: aarch64*-*-* The upcoming fix for PR96373 means that, without -fno-trapping-math, we can no longer optimise abs(a - b) to absolute-difference(a, b) for predicated SVE loops. The subtraction becomes predicated, and so we have the equivalent of: abs(IFN_COND_SUB(loopmask, a, b, c)) where c is the fallback/else value. It isn't possible to tell from this expression alone that the value of the abs result doesn't matter for false loopmask elements (and that c will do just as well as abs(c)). It therefore isn't possible to fold this into a conditional absolute difference without further information. One possible fix would be to add a gimple value and RTL object that represents an unknown/undefined/don't-care value, a bit like LLVM's undef. Another would be to make absolute difference a recognised gimple operation (via ifns) and make the vectoriser produce it directly. Or we could add a pass that back-propagates information about uses to discover which elements of a vector actually matter (which I think would also require gimple-level absolute difference).