[llvm-commits] [llvm] r56997 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Duncan Sands baldrick at free.fr
Fri Oct 3 00:41:47 PDT 2008


Author: baldrick
Date: Fri Oct  3 02:41:46 2008
New Revision: 56997

URL: http://llvm.org/viewvc/llvm-project?rev=56997&view=rev
Log:
The result of getSetCCResultType (eg: i32) may be larger
than the type an i1 is promoted to (eg: i8).  Account
for this.  Noticed by Tilmann Scheller on CellSPU; he
will hopefully take care of fixing this in LegalizeDAG
and adding a testcase!

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=56997&r1=56996&r2=56997&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Fri Oct  3 02:41:46 2008
@@ -365,10 +365,14 @@
 }
 
 SDValue DAGTypeLegalizer::PromoteIntRes_SETCC(SDNode *N) {
-  assert(isTypeLegal(TLI.getSetCCResultType(N->getOperand(0)))
-         && "SetCC type is not legal??");
-  return DAG.getNode(ISD::SETCC, TLI.getSetCCResultType(N->getOperand(0)),
-                     N->getOperand(0), N->getOperand(1), N->getOperand(2));
+  MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+  MVT SVT = TLI.getSetCCResultType(N->getOperand(0));
+  assert(isTypeLegal(SVT) && "SetCC type not legal??");
+  assert(NVT.getSizeInBits() <= SVT.getSizeInBits() &&
+         "Integer type overpromoted?");
+  return DAG.getNode(ISD::TRUNCATE, NVT,
+                     DAG.getNode(ISD::SETCC, SVT, N->getOperand(0),
+                                 N->getOperand(1), N->getOperand(2)));
 }
 
 SDValue DAGTypeLegalizer::PromoteIntRes_SHL(SDNode *N) {





More information about the llvm-commits mailing list