[PATCH] D49837: [SelectionDAG] Handle unary SelectPatternFlavor for ABS case in SelectionDAGBuilder::visitSelect.
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 30 08:42:49 PDT 2018
spatel added inline comments.
================
Comment at: lib/Analysis/ValueTracking.cpp:4856
// (-X >s 0) ? -X : X or (-X >s -1) ? -X : X --> ABS(X)
- if (Pred == ICmpInst::ICMP_SGT && match(CmpRHS, ZeroOrAllOnes))
+ if ((Pred == ICmpInst::ICMP_SGT || Pred == ICmpInst::ICMP_SGE) && match(CmpRHS, ZeroOrAllOnes))
return {SPF_ABS, SPNB_NA, false};
----------------
This is saying that:
X >= -1 ? X : -X
...is an abs(). But that's not correct:
https://rise4fun.com/Alive/eVzs
This diff should be split into its own patch and include correctness tests. Preferably, the tests can go in:
llvm/unittests/Analysis/ValueTrackingTest.cpp
Repository:
rL LLVM
https://reviews.llvm.org/D49837
More information about the llvm-commits
mailing list