[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon May 9 15:17:30 PDT 2005
Changes in directory llvm/lib/CodeGen/SelectionDAG:
SelectionDAGISel.cpp updated: 1.50 -> 1.51
---
Log message:
The semantics of cast X to bool are a comparison against zero, not a truncation!
---
Diffs of the changes: (+5 -0)
SelectionDAGISel.cpp | 5 +++++
1 files changed, 5 insertions(+)
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.50 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.51
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.50 Mon May 9 15:22:36 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon May 9 17:17:13 2005
@@ -493,6 +493,11 @@
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?
More information about the llvm-commits
mailing list