[llvm] [InstCombine] Fold more 'fcmp' 'select' instrs idioms into 'fabs' (PR #83381)

Andy Kaylor via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 1 12:03:39 PST 2024


andykaylor wrote:

> I'm wondering whether we should be propagating the function-level attributes to instruction flags _somewhere_ so that this is handled generically, rather than in individual folds?

The problem is in deciding where to do that. I don't like the function attributes and have made a few attempts to have them deprecated, but there are cases that couldn't be solved without them. This case, as detailed in #51601, is one such example. The front end can't set the fast-math flags on load instructions, so they never make it to the phi instruction that gets created. Propogating the flags from the attribute to instructions wouldn't help unless it was done after SROA and/or SimplifyCFG, but maybe those passes could add the flag based on the function-level attribute. That might be a better way to fix this.

https://github.com/llvm/llvm-project/pull/83381


More information about the llvm-commits mailing list