This patch add a function foldSelectToFabs, and do more combine for
fneg-of-fabs.
With 'nsz'
fold (X < +/-0.0) ? X : -X or (X <= +/-0.0) ? X : -X to -fabs(x) fold (X > +/-0.0) ? X : -X or (X >= +/-0.0) ? X : -X to -fabs(x)
Differential D123830
[InstCombine] Complete folding of fneg-of-fabs Chenbing.Zheng on Apr 14 2022, 7:40 PM. Authored by
Details This patch add a function foldSelectToFabs, and do more combine for With 'nsz' fold (X < +/-0.0) ? X : -X or (X <= +/-0.0) ? X : -X to -fabs(x) fold (X > +/-0.0) ? X : -X or (X >= +/-0.0) ? X : -X to -fabs(x)
Diff Detail
Event TimelineComment Actions This doesn't solve the root problem. If we start with the existing code in the test that is changing, it will not become fneg(fabs) like we want? We should extend the code under InstCombinerImpl::visitSelectInst() to match "nabs" patterns. Search for: "// Canonicalize select with fcmp to fabs()."
Comment Actions Yes, this looks nicer. See inline for some small improvements.
|