summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2017-07-02 14:34:50 +0000
committerSanjay Patel <spatel@rotateright.com>2017-07-02 14:34:50 +0000
commitc3d5cf0bb71f4278ae2e489cefbbe031522e97b3 (patch)
treeb05dd944d10f6be9cbf83d267b9b04509d543953 /llvm/lib/Transforms
parent91a00b974d13d0ced39ded2ca29fe03ef16652f7 (diff)
downloadbcm5719-llvm-c3d5cf0bb71f4278ae2e489cefbbe031522e97b3.tar.gz
bcm5719-llvm-c3d5cf0bb71f4278ae2e489cefbbe031522e97b3.zip
[InstCombine] look through bswap/bitreverse for equality comparisons
I noticed this missed bswap optimization in the CGP memcmp() expansion, and then I saw that we don't have the fold in InstCombine. Differential Revision: https://reviews.llvm.org/D34763 llvm-svn: 306980
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 58b8b2f5262..11507ae72b9 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -3438,6 +3438,15 @@ Instruction *InstCombiner::foldICmpEquality(ICmpInst &I) {
}
}
+ // If both operands are byte-swapped or bit-reversed, just compare the
+ // original values.
+ // TODO: Move this to a function similar to foldICmpIntrinsicWithConstant()
+ // and handle more intrinsics.
+ if ((match(Op0, m_BSwap(m_Value(A))) && match(Op1, m_BSwap(m_Value(B)))) ||
+ (match(Op0, m_Intrinsic<Intrinsic::bitreverse>(m_Value(A))) &&
+ match(Op1, m_Intrinsic<Intrinsic::bitreverse>(m_Value(B)))))
+ return new ICmpInst(Pred, A, B);
+
return nullptr;
}
OpenPOWER on IntegriCloud