summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-02 00:00:03 +0000
committerChris Lattner <sabre@nondot.org>2010-01-02 00:00:03 +0000
commit1eea3b0adab77358000e56cbf0804290a0c96375 (patch)
tree2851a96e3d6e78c92d9b68095e35f0b864031e8b /llvm/lib/CodeGen/SelectionDAG
parent6eef072eb67cf17952e39dcb0814cf2d29978f4b (diff)
downloadbcm5719-llvm-1eea3b0adab77358000e56cbf0804290a0c96375.tar.gz
bcm5719-llvm-1eea3b0adab77358000e56cbf0804290a0c96375.zip
Teach codegen to handle:
(X != null) | (Y != null) --> (X|Y) != 0 (X == null) & (Y == null) --> (X|Y) == 0 so that instcombine can stop doing this for pointers. This is part of PR3351, which is a case where instcombine doing this for pointers (inserting ptrtoint) is pessimizing code. llvm-svn: 92406
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 74d624f3647..40eb9eeb82a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1195,6 +1195,18 @@ SelectionDAGBuilder::ShouldEmitAsBranches(const std::vector<CaseBlock> &Cases){
return false;
}
+ // Handle: (X != null) | (Y != null) --> (X|Y) != 0
+ // Handle: (X == null) & (Y == null) --> (X|Y) == 0
+ if (Cases[0].CmpRHS == Cases[1].CmpRHS &&
+ Cases[0].CC == Cases[1].CC &&
+ isa<Constant>(Cases[0].CmpRHS) &&
+ cast<Constant>(Cases[0].CmpRHS)->isNullValue()) {
+ if (Cases[0].CC == ISD::SETEQ && Cases[0].TrueBB == Cases[1].ThisBB)
+ return false;
+ if (Cases[0].CC == ISD::SETNE && Cases[0].FalseBB == Cases[1].ThisBB)
+ return false;
+ }
+
return true;
}
OpenPOWER on IntegriCloud