<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 1, 2014 at 8:07 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: chandlerc<br>
Date: Tue Jul  1 22:07:15 2014<br>
New Revision: 212158<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=212158&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=212158&view=rev</a><br>
Log:<br>
[cleanup] Hoist the promotion dispatch logic into the promote function<br>
so that we can use return to express it more cleanly and avoid so many<br>
nested switch statements.<br>
<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp<br>
<br>
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp?rev=212158&r1=212157&r2=212158&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp?rev=212158&r1=212157&r2=212158&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp Tue Jul  1 22:07:15 2014<br>
@@ -281,27 +281,11 @@ SDValue VectorLegalizer::LegalizeOp(SDVa<br>
<br>
   switch (TLI.getOperationAction(Node->getOpcode(), QueryType)) {<br>
   case TargetLowering::Promote:<br>
-    switch (Op.getOpcode()) {<br>
-    default:<br>
-      // "Promote" the operation by bitcasting<br>
-      Result = Promote(Op);<br>
-      Changed = true;<br>
-      break;<br>
-    case ISD::SINT_TO_FP:<br>
-    case ISD::UINT_TO_FP:<br>
-      // "Promote" the operation by extending the operand.<br>
-      Result = PromoteINT_TO_FP(Op);<br>
-      Changed = true;<br>
-      break;<br>
-    case ISD::FP_TO_UINT:<br>
-    case ISD::FP_TO_SINT:<br>
-      // Promote the operation by extending the operand.<br>
-      Result = PromoteFP_TO_INT(Op, Op->getOpcode() == ISD::FP_TO_SINT);<br>
-      Changed = true;<br>
-      break;<br>
-    }<br>
+    Result = Promote(Op);<br>
+    Changed = true;<br>
+    break;<br>
+  case TargetLowering::Legal:<br>
     break;<br>
-  case TargetLowering::Legal: break;<br>
   case TargetLowering::Custom: {<br>
     SDValue Tmp1 = TLI.LowerOperation(Op, DAG);<br>
     if (Tmp1.getNode()) {<br>
@@ -343,9 +327,24 @@ SDValue VectorLegalizer::LegalizeOp(SDVa<br>
 }<br>
<br>
 SDValue VectorLegalizer::Promote(SDValue Op) {<br>
-  // Vector "promotion" is basically just bitcasting and doing the operation<br>
-  // in a different type.  For example, x86 promotes ISD::AND on v2i32 to<br>
-  // v1i64.<br>
+  // For a few operations there is a specific concept for promotion based on<br>
+  // the operand's type.<br>
+  switch (Op.getOpcode()) {<br>
+  case ISD::SINT_TO_FP:<br>
+  case ISD::UINT_TO_FP:<br>
+    // "Promote" the operation by extending the operand.<br>
+    return PromoteINT_TO_FP(Op);<br>
+    break;<br></blockquote><div><br></div><div>Delete the break?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  case ISD::FP_TO_UINT:<br>
+  case ISD::FP_TO_SINT:<br>
+    // Promote the operation by extending the operand.<br>
+    return PromoteFP_TO_INT(Op, Op->getOpcode() == ISD::FP_TO_SINT);<br>
+    break;<br></blockquote><div><br></div><div>Same as above. </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  }<br>
+<br>
+  // The rest of the time, vector "promotion" is basically just bitcasting and<br>
+  // doing the operation in a different type.  For example, x86 promotes<br>
+  // ISD::AND on v2i32 to v1i64.<br>
   MVT VT = Op.getSimpleValueType();<br>
   assert(Op.getNode()->getNumValues() == 1 &&<br>
          "Can't promote a vector with multiple results!");<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>~Craig
</div></div>