[llvm-commits] [llvm] r37851 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Chris Lattner clattner at apple.com
Tue Jul 3 09:23:19 PDT 2007


On Jul 3, 2007, at 7:43 AM, Duncan Sands wrote:
> Hi Dan,
>> +  // fold (add x, undef) -> undef
>> +  if (N1.getOpcode() == ISD::UNDEF)
>> +    return N1;
>
> what if N0 is undef and not N1?

Presumably, undef is being canonicalized to the RHS somewhere. I  
don't know if this is actually true in the dag combiner though, it  
should be checked.

>> +  // fold (mul x, undef) -> 0
>> +  if (N1.getOpcode() == ISD::UNDEF)
>> +    return DAG.getConstant(0, VT);
>
> Yes, this seems better :)  Again, is the undef guaranteed to be
> in N1 and not N0?

Does this work for vectors?  Does DAG.getConstant(0, MVT::v4i32)  
work?  This xform should probably be disabled after legalize for  
vectors.

>> +  // fold (or x, undef) -> -1
>> +  if (N1.getOpcode() == ISD::UNDEF)
>> +    return DAG.getConstant(-1, VT);
>
> Is this the right way to get an all-bits-one value?

Yes, but this has the same problem with vectors. :)

-Chris





More information about the llvm-commits mailing list