[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Evan Cheng
evan.cheng at apple.com
Tue May 1 01:53:58 PDT 2007
Doh. Brain cramp.
Evan
On Apr 30, 2007, at 9:39 PM, Chris Lattner wrote:
>> + bool HasUses = false;
>> + SmallVector<MVT::ValueType, 2> VTs;
>> + for (unsigned i = 0, e = N->getNumValues(); i != e; ++i) {
>> + if (!N->hasNUsesOfValue(0, i)) {
>> + HasUses = true;
>> + break;
>> + }
>> + VTs.push_back(N->getValueType(i));
>> + }
>> + if (!HasUses) {
>> + SmallVector<SDOperand, 1> Ops;
>> + return CombineTo(N, DAG.getNode(ISD::UNDEF, &VTs[0], VTs.size
>> (), 0, 0),
>> + Chain);
>
> This can never trigger and isn't right if it did.
>
> #1: This should trigger if the chain has uses but the other values do
> not. If the entire node is dead, it will already have been removed.
>
> #2. you can't create an undef with multiple results, you have to
> create multiple undefs :)
>
> I'd suggest just writing this as:
>
> if (N->getValueType(1) == MVT::Other) {
> // single result case.
> } else {
> assert(N->getValueType(2) == MVT::Other);
> // multi result case.
> }
>
> This lets you drop the looping and smallvector.
>
> -Chris
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list