diff options
author | Chris Lattner <sabre@nondot.org> | 2008-05-09 05:19:28 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-05-09 05:19:28 +0000 |
commit | aaba10e8435b26d71b27a03b4e2efeb86c153891 (patch) | |
tree | 7077de93e013b1de74fba9cb952b20a750b77d18 /llvm/lib/Transforms | |
parent | e7f0afe1680166832cdafdcabd001ac7864e81ba (diff) | |
download | bcm5719-llvm-aaba10e8435b26d71b27a03b4e2efeb86c153891.tar.gz bcm5719-llvm-aaba10e8435b26d71b27a03b4e2efeb86c153891.zip |
Implement PR2298. This transforms:
~x < ~y --> y < x
-x == -y --> x == y
llvm-svn: 50882
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 772ef63121b..e8b60f890c2 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -5658,8 +5658,21 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { return R; } + // ~x < ~y --> y < x + { Value *A, *B; + if (match(Op0, m_Not(m_Value(A))) && + match(Op1, m_Not(m_Value(B)))) + return new ICmpInst(I.getPredicate(), B, A); + } + if (I.isEquality()) { Value *A, *B, *C, *D; + + // -x == -y --> x == y + if (match(Op0, m_Neg(m_Value(A))) && + match(Op1, m_Neg(m_Value(B)))) + return new ICmpInst(I.getPredicate(), A, B); + if (match(Op0, m_Xor(m_Value(A), m_Value(B)))) { if (A == Op1 || B == Op1) { // (A^B) == A -> B == 0 Value *OtherVal = A == Op1 ? B : A; |