[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelLowering.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Sep 1 16:44:43 PDT 2005



Changes in directory llvm/lib/Target/PowerPC:

PPC32ISelLowering.cpp updated: 1.17 -> 1.18
---
Log message:

Implement small-arguments.ll:test3 by teaching the DAG optimizer that
the results of calls to functions returning small values are properly
sign/zero extended.


---
Diffs of the changes:  (+16 -2)

 PPC32ISelLowering.cpp |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)


Index: llvm/lib/Target/PowerPC/PPC32ISelLowering.cpp
diff -u llvm/lib/Target/PowerPC/PPC32ISelLowering.cpp:1.17 llvm/lib/Target/PowerPC/PPC32ISelLowering.cpp:1.18
--- llvm/lib/Target/PowerPC/PPC32ISelLowering.cpp:1.17	Wed Aug 31 16:09:52 2005
+++ llvm/lib/Target/PowerPC/PPC32ISelLowering.cpp	Thu Sep  1 18:44:32 2005
@@ -613,8 +613,12 @@
   
   std::vector<MVT::ValueType> RetVals;
   MVT::ValueType RetTyVT = getValueType(RetTy);
+  MVT::ValueType ActualRetTyVT = RetTyVT;
+  if (RetTyVT >= MVT::i1 && RetTyVT <= MVT::i16)
+    ActualRetTyVT = MVT::i32;   // Promote result to i32.
+    
   if (RetTyVT != MVT::isVoid)
-    RetVals.push_back(RetTyVT);
+    RetVals.push_back(ActualRetTyVT);
   RetVals.push_back(MVT::Other);
   
   SDOperand TheCall = SDOperand(DAG.getCall(RetVals,
@@ -622,7 +626,17 @@
   Chain = TheCall.getValue(RetTyVT != MVT::isVoid);
   Chain = DAG.getNode(ISD::CALLSEQ_END, MVT::Other, Chain,
                       DAG.getConstant(NumBytes, getPointerTy()));
-  return std::make_pair(TheCall, Chain);
+  SDOperand RetVal = TheCall;
+  
+  // If the result is a small value, add a note so that we keep track of the
+  // information about whether it is sign or zero extended.
+  if (RetTyVT != ActualRetTyVT) {
+    RetVal = DAG.getNode(RetTy->isSigned() ? ISD::AssertSext : ISD::AssertZext,
+                         MVT::i32, RetVal, DAG.getValueType(RetTyVT));
+    RetVal = DAG.getNode(ISD::TRUNCATE, RetTyVT, RetVal);
+  }
+  
+  return std::make_pair(RetVal, Chain);
 }
 
 SDOperand PPC32TargetLowering::LowerVAStart(SDOperand Chain, SDOperand VAListP,






More information about the llvm-commits mailing list