projects
/
oota-llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
edcee6f
)
The semantics of cast X to bool are a comparison against zero, not a truncation!
author
Chris Lattner
<sabre@nondot.org>
Mon, 9 May 2005 22:17:13 +0000
(22:17 +0000)
committer
Chris Lattner
<sabre@nondot.org>
Mon, 9 May 2005 22:17:13 +0000
(22:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21833
91177308
-0d34-0410-b5e6-
96231b3b80d8
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
patch
|
blob
|
history
diff --git
a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 8dbf78c270e168648f3bc45cbb17d896a618a8f2..d6ec50ae166e757e37e04a8ff853abbf7b634c57 100644
(file)
--- a/
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/
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?