summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-05-09 22:17:13 +0000
committerChris Lattner <sabre@nondot.org>2005-05-09 22:17:13 +0000
commit2d8b55c4769d905f588d9eb95e66674e7bdbb3db (patch)
tree09c6c1f097ee27c3d422439d00e3486854609de3 /llvm/lib/CodeGen/SelectionDAG
parent763a9e8c9b04d1f962469096d1af3131b008855a (diff)
downloadbcm5719-llvm-2d8b55c4769d905f588d9eb95e66674e7bdbb3db.tar.gz
bcm5719-llvm-2d8b55c4769d905f588d9eb95e66674e7bdbb3db.zip
The semantics of cast X to bool are a comparison against zero, not a truncation!
llvm-svn: 21833
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 8dbf78c270e..d6ec50ae166 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -493,6 +493,11 @@ void SelectionDAGLowering::visitCast(User &I) {
if (N.getValueType() == DestTy) {
setValue(&I, N); // noop cast.
+ } else if (DestTy == MVT::i1) {
+ // Cast to bool is a comparison against zero, not truncation to zero.
+ SDOperand Zero = isInteger(SrcTy) ? DAG.getConstant(0, N.getValueType()) :
+ DAG.getConstantFP(0.0, N.getValueType());
+ setValue(&I, DAG.getSetCC(ISD::SETNE, MVT::i1, N, Zero));
} else if (isInteger(SrcTy)) {
if (isInteger(DestTy)) { // Int -> Int cast
if (DestTy < SrcTy) // Truncating cast?
OpenPOWER on IntegriCloud