[llvm-commits] [llvm] r62383 - in /llvm/trunk: lib/CodeGen/SelectionDAG/DAGCombiner.cpp test/CodeGen/X86/scalar-extract.ll

Duncan Sands baldrick at free.fr
Sat Jan 17 01:43:50 PST 2009


Hi Mon Ping,

> +  SDValue InVec = N->getOperand(0);
> +  SDValue EltNo = N->getOperand(1);
> +
> +  if (isa<ConstantSDNode>(EltNo)) {
> +    unsigned Elt = cast<ConstantSDNode>(EltNo)->getZExtValue();
> +    if (InVec.getOpcode() == ISD::SCALAR_TO_VECTOR && Elt == 0) {
> +      return InVec.getOperand(0);
> +    }
> +  }

I don't think you need to check EltNo at all: if it's not the first
element then the value is undefined, i.e. you can assume it is whatever
is convenient to you.  In particular you may assume that it is the same
as the first element.  In short: if the input is SCALAR_TO_VECTOR, you
can always return InVec.getOperand(0) regardless of EltNo.

Ciao,

Duncan.



More information about the llvm-commits mailing list