diff options
author | Sanjay Patel <spatel@rotateright.com> | 2019-06-10 14:57:45 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2019-06-10 14:57:45 +0000 |
commit | 85de9634e641d29260f74907b72e2d26e2b4d9f7 (patch) | |
tree | 8a8bbf53604e88ac628ffc8786de2b6a7ffefba6 /llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | |
parent | 306e474b91466d7eb6fd0bb5af9e0de2c2cb66a5 (diff) | |
download | bcm5719-llvm-85de9634e641d29260f74907b72e2d26e2b4d9f7.tar.gz bcm5719-llvm-85de9634e641d29260f74907b72e2d26e2b4d9f7.zip |
[InstCombine] fix bug in canonicalization to fabs()
Forgot to translate the predicate clauses in rL362943.
llvm-svn: 362945
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp index ced2f10e937..808833d95ab 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -1878,14 +1878,16 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { Instruction *FSub; if (match(CondVal, m_FCmp(Pred, m_Specific(FalseVal), m_AnyZeroFP())) && match(TrueVal, m_FSub(m_PosZeroFP(), m_Specific(FalseVal))) && - match(TrueVal, m_Instruction(FSub)) && FSub->hasNoNaNs()) { + match(TrueVal, m_Instruction(FSub)) && FSub->hasNoNaNs() && + Pred == FCmpInst::FCMP_OLE) { Value *Fabs = Builder.CreateUnaryIntrinsic(Intrinsic::fabs, FalseVal, FSub); return replaceInstUsesWith(SI, Fabs); } // (X > +/-0.0) ? X : (0.0 - X) --> fabs(X) if (match(CondVal, m_FCmp(Pred, m_Specific(TrueVal), m_AnyZeroFP())) && match(FalseVal, m_FSub(m_PosZeroFP(), m_Specific(TrueVal))) && - match(FalseVal, m_Instruction(FSub)) && FSub->hasNoNaNs()) { + match(FalseVal, m_Instruction(FSub)) && FSub->hasNoNaNs() && + Pred == FCmpInst::FCMP_OGT) { Value *Fabs = Builder.CreateUnaryIntrinsic(Intrinsic::fabs, TrueVal, FSub); return replaceInstUsesWith(SI, Fabs); } |