[PATCH] D139310: InstCombine: Fold fneg (copysign x, y) -> copysign x, (fneg y)

Joshua Cranmer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 20 13:04:25 PST 2022


jcranmer-intel accepted this revision.
jcranmer-intel added a comment.
This revision is now accepted and ready to land.

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.



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:2443-2446
+    // The source copysign has an additional value input, so we can't propagate
+    // flags the copysign doesn't also have.
+    FastMathFlags FMF = I.getFastMathFlags();
+    FMF &= cast<FPMathOperator>(OneUse)->getFastMathFlags();
----------------
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.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139310/new/

https://reviews.llvm.org/D139310



More information about the llvm-commits mailing list