[llvm-commits] Patch for handling multiple values in ExpandIntegerOperand

sanjiv gupta sanjiv.gupta at microchip.com
Fri Oct 31 04:36:10 PDT 2008


On Fri, 2008-10-31 at 10:52 +0100, Duncan Sands wrote:
> Hi,
> 
> > Looks like some target independent code also requires that the number of
> > values can't be same. For example: TRUNC:i8 (add:i16) gets replaced by
> > the first value of adde:(i8, flag) ignoring the flag.
> 
> these routines are defined to return one value.  In the code in question
> that value needs to replace one value of N.  If N has more than one value,
> how do you know which one to replace?
> 
> > So the patch I submitted  is quite generic and only extends the
> > functionally to handle the case where the original node had multiple
> > values. Our target needs this since we are replacing loads, and a load
> > has multiple values. Do you think the patch is unsafe?
> 
> Yes, because it assumes that you want to replace the first values of N.
> I think it makes more sense to change everything (include the target
> independent routines) to return nodes rather than values, and have these
> new nodes entirely replace N.
> 
> Ciao,
> 
> Duncan.

The code routine in question here is DAG::getNode(), which returns an
SDValue.  When it sees that the Operand of the TRUNCATE:i8
(adde:i8,flag) has same value, it simply returns the first value of
Operand. I don't think that we can/want to change the return type of
getNode().

Probably you are referring to change the return types of functions like:

  SDValue DAGTypeLegalizer::ExpandIntOp_TRUNCATE(SDNode *N)

to SDNode *.

For example, change the above function to

SDNode* DAGTypeLegalizer::ExpandIntOp_TRUNCATE(SDNode *N) {
  SDValue InL, InH;
  GetExpandedInteger(N->getOperand(0), InL, InH);
  // Just truncate the low part of the source.
  SDValue Val = DAG.getNode(ISD::TRUNCATE, N->getValueType(0), InL);
  SDNode *Res = Val.getNode();
  
  // Return Merge_Values if the number of values of N and Res do not
match.  ???
  
   
}

is my understanding correct?

- Sanjiv




More information about the llvm-commits mailing list