diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2018-03-18 15:53:02 +0000 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2018-03-18 15:53:02 +0000 |
commit | e6da3063a54c801eab5ff3ab267341a4804f9e4b (patch) | |
tree | 4f429dc90c81b4b1350e462cb4dbbf7dc47e7c1b /llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | |
parent | e64f3b108d4896275ad89f5000bb389ad8eef758 (diff) | |
download | bcm5719-llvm-e6da3063a54c801eab5ff3ab267341a4804f9e4b.tar.gz bcm5719-llvm-e6da3063a54c801eab5ff3ab267341a4804f9e4b.zip |
[InstCombine] peek through unsigned FP casts for zero-equality compares (PR36682)
Summary:
This pattern came up in PR36682 / D44390
https://bugs.llvm.org/show_bug.cgi?id=36682
https://reviews.llvm.org/D44390
https://godbolt.org/g/oKvT5H
See also D44416
Reviewers: spatel, majnemer, efriedma, arsenm
Reviewed By: spatel
Subscribers: wdng, llvm-commits
Differential Revision: https://reviews.llvm.org/D44424
llvm-svn: 327799
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 0cd72bce45d..12894b7833b 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -4506,6 +4506,15 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { return New; } + Value *X; + + // Zero-equality checks are preserved through unsigned floating-point casts: + // icmp eq (bitcast (uitofp X)), 0 --> icmp eq X, 0 + // icmp ne (bitcast (uitofp X)), 0 --> icmp ne X, 0 + if (match(Op0, m_BitCast(m_UIToFP(m_Value(X))))) + if (I.isEquality() && match(Op1, m_Zero())) + return new ICmpInst(Pred, X, ConstantInt::getNullValue(X->getType())); + // Test to see if the operands of the icmp are casted versions of other // values. If the ptr->ptr cast can be stripped off both arguments, we do so // now. |