[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Jan 18 11:27:19 PST 2005
Changes in directory llvm/lib/CodeGen/SelectionDAG:
LegalizeDAG.cpp updated: 1.41 -> 1.42
---
Log message:
Fix some fixmes (promoting bools for select and brcond), fix promotion
of zero and sign extends.
---
Diffs of the changes: (+43 -8)
Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.41 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.42
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.41 Tue Jan 18 11:54:55 2005
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Tue Jan 18 13:27:06 2005
@@ -320,8 +320,16 @@
case ISD::BRCOND:
Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
- // FIXME: booleans might not be legal!
- Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the condition.
+
+ switch (getTypeAction(Node->getOperand(1).getValueType())) {
+ case Expand: assert(0 && "It's impossible to expand bools");
+ case Legal:
+ Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the condition.
+ break;
+ case Promote:
+ Tmp2 = PromoteOp(Node->getOperand(1)); // Promote the condition.
+ break;
+ }
// Basic block destination (Op#2) is always legal.
if (Tmp1 != Node->getOperand(0) || Tmp2 != Node->getOperand(1))
Result = DAG.getNode(ISD::BRCOND, MVT::Other, Tmp1, Tmp2,
@@ -524,8 +532,15 @@
}
break;
case ISD::SELECT:
- // FIXME: BOOLS MAY REQUIRE PROMOTION!
- Tmp1 = LegalizeOp(Node->getOperand(0)); // Cond
+ switch (getTypeAction(Node->getOperand(0).getValueType())) {
+ case Expand: assert(0 && "It's impossible to expand bools");
+ case Legal:
+ Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the condition.
+ break;
+ case Promote:
+ Tmp1 = PromoteOp(Node->getOperand(0)); // Promote the condition.
+ break;
+ }
Tmp2 = LegalizeOp(Node->getOperand(1)); // TrueVal
Tmp3 = LegalizeOp(Node->getOperand(2)); // FalseVal
@@ -770,11 +785,15 @@
switch (Node->getOpcode()) {
case ISD::ZERO_EXTEND:
Result = PromoteOp(Node->getOperand(0));
- Result = DAG.getNode(ISD::ZERO_EXTEND_INREG, Result.getValueType(),
+ // NOTE: Any extend would work here...
+ Result = DAG.getNode(ISD::ZERO_EXTEND, Op.getValueType(), Result);
+ Result = DAG.getNode(ISD::ZERO_EXTEND_INREG, Op.getValueType(),
Result, Node->getOperand(0).getValueType());
break;
case ISD::SIGN_EXTEND:
Result = PromoteOp(Node->getOperand(0));
+ // NOTE: Any extend would work here...
+ Result = DAG.getNode(ISD::SIGN_EXTEND, Op.getValueType(), Result);
Result = DAG.getNode(ISD::SIGN_EXTEND_INREG, Result.getValueType(),
Result, Node->getOperand(0).getValueType());
break;
@@ -1101,7 +1120,15 @@
AddLegalizedOperand(Op.getValue(1), Result.getValue(1));
break;
case ISD::SELECT:
- Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the condition
+ switch (getTypeAction(Node->getOperand(0).getValueType())) {
+ case Expand: assert(0 && "It's impossible to expand bools");
+ case Legal:
+ Tmp1 = LegalizeOp(Node->getOperand(0));// Legalize the condition.
+ break;
+ case Promote:
+ Tmp1 = PromoteOp(Node->getOperand(0)); // Promote the condition.
+ break;
+ }
Tmp2 = PromoteOp(Node->getOperand(1)); // Legalize the op0
Tmp3 = PromoteOp(Node->getOperand(2)); // Legalize the op1
Result = DAG.getNode(ISD::SELECT, NVT, Tmp1, Tmp2, Tmp3);
@@ -1238,8 +1265,16 @@
}
case ISD::SELECT: {
SDOperand C, LL, LH, RL, RH;
- // FIXME: BOOLS MAY REQUIRE PROMOTION!
- C = LegalizeOp(Node->getOperand(0));
+
+ switch (getTypeAction(Node->getOperand(0).getValueType())) {
+ case Expand: assert(0 && "It's impossible to expand bools");
+ case Legal:
+ C = LegalizeOp(Node->getOperand(0)); // Legalize the condition.
+ break;
+ case Promote:
+ C = PromoteOp(Node->getOperand(0)); // Promote the condition.
+ break;
+ }
ExpandOp(Node->getOperand(1), LL, LH);
ExpandOp(Node->getOperand(2), RL, RH);
Lo = DAG.getNode(ISD::SELECT, NVT, C, LL, RL);
More information about the llvm-commits
mailing list