[llvm-commits] [llvm] r68996 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/DAGCombiner.cpp lib/CodeGen/SelectionDAG/LegalizeDAG.cpp lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Duncan Sands baldrick at free.fr
Sat Apr 18 23:48:34 PDT 2009


Hi Bob,

> >      if (Op.getValueType() != SrcEltVT) {
> >        if (Op.getOpcode() == ISD::UNDEF)
> >          Op = DAG.getUNDEF(SrcEltVT);
> >        else
> >          Op = DAG.getNode(ISD::TRUNCATE, BV->getDebugLoc(),  
> > SrcEltVT, Op);
> >      }
> >
> > I think this can just be
> >
> >      if (Op.getValueType() != SrcEltVT)
> >        Op = DAG.getNode(ISD::TRUNCATE, BV->getDebugLoc(), SrcEltVT,  
> > Op);
> >
> > because the UNDEF case should be handled automatically by DAG.getNode,
> > or if not by the DAG combiner.
> 
> OK.  I had checked the DAG.getNode code and it didn't seem to handle  
> this case.  I will take your word for it that the DAG combiner will  
> take care of it.  Thanks!

in any case, as a general rule I reckon it's better to teach getNode to
do this kind of optimization rather than doing it sporadically here and
there.

Ciao,

Duncan.



More information about the llvm-commits mailing list