Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2007-07-03 Thread Chris Lattner
On Jun 29, 2007, at 1:10 AM, Duncan Sands wrote: > Hi, > > It seems like folding undef/X to undef isn't safe either though, > > here is my understanding of how to fold undef. I hope it clarifies > this confusing area. Of course, I could be confused myself but I > hope not :) > > (1) When is

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp LegalizeDAG.cpp SelectionDAG.cpp SelectionDAGISel.cpp TargetLowering.cpp

2007-07-03 Thread Chris Lattner
On Jul 3, 2007, at 2:13 PM, Dan Gohman wrote: >>> We overload ISD::FADD and quite a lot of others. Why not >>> ISD::ConstantFP too? >> >> Fair enough, after pondering on it, I agree with you. The proposed >> semantics are that a ConstantFP (and also a normal Constant?) produce >> the splatted im

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp LegalizeDAG.cpp SelectionDAG.cpp SelectionDAGISel.cpp TargetLowering.cpp

2007-07-03 Thread Dan Gohman
>> We overload ISD::FADD and quite a lot of others. Why not >> ISD::ConstantFP too? > > Fair enough, after pondering on it, I agree with you. The proposed > semantics are that a ConstantFP (and also a normal Constant?) produce > the splatted immediate value? Constant sounds good too. And U

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp LegalizeDAG.cpp SelectionDAG.cpp SelectionDAGISel.cpp TargetLowering.cpp

2007-07-02 Thread Chris Lattner
On Jun 29, 2007, at 12:38 PM, Dan Gohman wrote: >>> Just as there isn't a special ADD node kind for vectors -- just >>> an ADD >>> kind with nodes that can have a vector ValueType, ConstantFP can >>> also >>> be "vectorized". A ConstantFP with a vector ValueType is a vector >>> constant, >>>

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp LegalizeDAG.cpp SelectionDAG.cpp SelectionDAGISel.cpp TargetLowering.cpp

2007-06-29 Thread Dan Gohman
>> Just as there isn't a special ADD node kind for vectors -- just an ADD >> kind with nodes that can have a vector ValueType, ConstantFP can also >> be "vectorized". A ConstantFP with a vector ValueType is a vector >> constant, >> equivalent to what is currently represented as a splat BUILD_VECT

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2007-06-29 Thread Dan Gohman
> Duncan pointed out that I confused myself. If something is undef, we > can choose to pick any specific value for the undef to pick the > cancellation. Thanks Chris and Duncan for explaining this. I'll submit a fix for the DAGCombiner changes accordingly. Dan -- Dan Gohman, Cray Inc.

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2007-06-28 Thread Chris Lattner
On Jun 27, 2007, at 1:50 PM, Dan Gohman wrote: I think that undef udiv intmax -> 0, no? If not, plz update instcombine as well. >>> >>> intmax udiv intmax -> 1. >>> It seems like folding undef/X to undef isn't safe either though, >>> with >>> the way it sounds like undef is intended

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2007-06-28 Thread Chris Lattner
On Jun 28, 2007, at 3:09 AM, Duncan Sands wrote: > Hi, > >>> It seems like folding undef/X to undef isn't safe either though, >>> with >>> the way it sounds like undef is intended to work. This code: >>> >>> %x = udiv i32 undef, %intmax >>> %y = udiv i32 %x, 2 >>> >>> will always set %y to

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2007-06-27 Thread Dan Gohman
>>> I think that undef udiv intmax -> 0, no? If not, plz update >>> instcombine as well. >> >> intmax udiv intmax -> 1. >> >> It seems like folding undef/X to undef isn't safe either though, with >> the way it sounds like undef is intended to work. This code: >> >> %x = udiv i32 undef, %intmax >

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2007-06-27 Thread Chris Lattner
>> I think that undef udiv intmax -> 0, no? If not, plz update >> instcombine as well. > > intmax udiv intmax -> 1. > > It seems like folding undef/X to undef isn't safe either though, with > the way it sounds like undef is intended to work. This code: > > %x = udiv i32 undef, %intmax > %y = u

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp LegalizeDAG.cpp SelectionDAG.cpp SelectionDAGISel.cpp TargetLowering.cpp

2007-06-27 Thread Chris Lattner
On Jun 27, 2007, at 7:59 AM, Dan Gohman wrote: >>> Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >>> diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.409 llvm/ >>> lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.410 >>> --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.409Fri J

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2007-06-27 Thread Dan Gohman
+ + // If either operand is undef, the result is undef + if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF) +return DAG.getNode(ISD::UNDEF, VT); + return SDOperand(); } >>> >>> This is not safe for sdiv/udiv. Safe xforms are: >>> >>>/

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp LegalizeDAG.cpp SelectionDAG.cpp SelectionDAGISel.cpp TargetLowering.cpp

2007-06-27 Thread Dan Gohman
>> Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >> diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.409 llvm/ >> lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.410 >> --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.409 Fri Jun 22 >> 09:59:07 2007 >> +++ llvm/lib/CodeGen/Se

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp LegalizeDAG.cpp SelectionDAG.cpp SelectionDAGISel.cpp TargetLowering.cpp

2007-06-26 Thread Chris Lattner
> --- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.500 Fri Jun 22 > 09:59:07 2007 > +++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Mon Jun 25 > 11:23:39 2007 > @@ -173,15 +173,13 @@ > + /// ScalarizeVectorOp - Given an operand of vector type, convert > it into the > + /// eq

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2007-06-26 Thread Chris Lattner
> Thanks for all the review comments! I've addressed a few comments > below; I'll get to the others soon. Thanks! I also filed pr1529, which is the only failure that showed on the ppc nightly tester. >>> @@ -1162,6 +1179,11 @@ >>> SDOperand Op = BuildSDIV(N); >>> if (Op.Val) return O

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2007-06-26 Thread Dan Gohman
Hi Chris, Thanks for all the review comments! I've addressed a few comments below; I'll get to the others soon. >> @@ -1162,6 +1179,11 @@ >> SDOperand Op = BuildSDIV(N); >> if (Op.Val) return Op; >>} >> + >> + // If either operand is undef, the result is undef >> + if (N0.getOpcod

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2007-06-25 Thread Chris Lattner
Another great change. > @@ -856,6 +844,10 @@ >ConstantSDNode *N0C = dyn_cast(N0); >ConstantSDNode *N1C = dyn_cast(N1); >MVT::ValueType VT = N0.getValueType(); > + > + // fold vector ops > + SDOperand FoldedVOp = SimplifyVBinOp(N); > + if (FoldedVOp.Val) return FoldedVOp; I'm co

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp LegalizeDAG.cpp SelectionDAG.cpp SelectionDAGISel.cpp TargetLowering.cpp

2007-06-22 Thread Chris Lattner
On Jun 22, 2007, at 7:59 AM, Dan Gohman wrote: > Move ComputeMaskedBits, MaskedValueIsZero, and ComputeNumSignBits from > TargetLowering to SelectionDAG so that they have more convenient > access to the current DAG, in preparation for the ValueType routines > being changed from standalone functio

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2007-05-15 Thread Chris Lattner
> Fix an infinite recursion in GetNegatedExpression. Doh, thanks a lot Lauro! -Chris > > > --- > Diffs of the changes: (+1 -1) > > DAGCombiner.cpp |2 +- > 1 files changed, 1 insertion(+), 1 deletion(-) > > > Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp > diff -u llvm/lib/CodeGen/S

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2007-05-01 Thread Chris Lattner
> Forgot about chain result; also UNDEF cannot have multiple values. Nice! Thanks Evan, -Chris > --- > Diffs of the changes: (+12 -12) > > DAGCombiner.cpp | 24 > 1 files changed, 12 insertions(+), 12 deletions(-) > > > Index: llvm/lib/CodeGen/SelectionDAG/DAGCombine

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2007-05-01 Thread Evan Cheng
Doh. Brain cramp. Evan On Apr 30, 2007, at 9:39 PM, Chris Lattner wrote: >> +bool HasUses = false; >> +SmallVector VTs; >> +for (unsigned i = 0, e = N->getNumValues(); i != e; ++i) { >> + if (!N->hasNUsesOfValue(0, i)) { >> +HasUses = true; >> +break; >> + }

Re: [llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2007-04-30 Thread Chris Lattner
> +bool HasUses = false; > +SmallVector 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) { > +