This is an archive of the discontinued LLVM Phabricator instance.

InstCombine: Fold fneg (copysign x, y) -> copysign x, (fneg y)
ClosedPublic

Authored by arsenm on Dec 5 2022, 5:11 AM.

Diff Detail

Event Timeline

arsenm created this revision.Dec 5 2022, 5:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2022, 5:11 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
arsenm requested review of this revision.Dec 5 2022, 5:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2022, 5:11 AM
Herald added a subscriber: wdng. · View Herald Transcript
arsenm updated this revision to Diff 480437.Dec 6 2022, 5:07 AM

Move CreateCopySign to correct patch

jcranmer-intel accepted this revision.Dec 20 2022, 1:04 PM

There might be some cases where we can maintain some fast-math flags that would otherwise be dropped... but it's almost certainly not worth the bother here, since I expect the vast majority of cases will have all the relevant operations have the same fast-math flags.

llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
2443–2446

It took me some thinking through all the cases, but I'm now convinced that it's required that both the fneg and copysign *need* to get the intersection of fast-math flags.

This revision is now accepted and ready to land.Dec 20 2022, 1:04 PM
arsenm closed this revision.EditedDec 20 2022, 2:14 PM
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
2443–2446

I eventually just wrote out all the cases and let alive2 tell me it was wrong