[llvm-commits] [llvm] r48673 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAG.h lib/CodeGen/SelectionDAG/DAGCombiner.cpp lib/CodeGen/SelectionDAG/SelectionDAG.cpp test/CodeGen/X86/dagcombine-cse.ll
Chris Lattner
clattner at apple.com
Fri Mar 21 20:17:06 PDT 2008
On Mar 21, 2008, at 6:55 PM, Evan Cheng wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=48673&view=rev
> Log:
> Teach DAG combiner to commute commutable binary nodes in order to
> achieve sdisel CSE.
Nice!
> + // If N is a commutative binary node, try commuting it to enable
> more
> + // sdisel CSE.
> + if (RV.Val == 0 &&
> + SelectionDAG::isCommutativeBinOp(N->getOpcode()) &&
> + N->getNumValues() == 1) {
> + SDOperand N0 = N->getOperand(0);
> + SDOperand N1 = N->getOperand(1);
> + // Constant operands are canonicalized to RHS.
> + if (isa<ConstantSDNode>(N0) || !isa<ConstantSDNode>(N1)) {
> + SDOperand Ops[] = { N1, N0 };
> + SDNode *CSENode = DAG.getNodeIfExists(N->getOpcode(), N-
> >getVTList(),
> + Ops, 2);
Ok, all this seems pretty reasonable.
> + if (CSENode && CSENode->use_size() <= N->use_size())
Why are you comparing use_size? use_size is soon to be a linear time
operation, but in any case, I don't see why the # of uses should
affect which one "wins".
-Chris
More information about the llvm-commits
mailing list