diff options
author | Bill Wendling <isanbard@gmail.com> | 2009-01-30 20:50:00 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2009-01-30 20:50:00 +0000 |
commit | 6af7618b2378a3af378d681914976483b5b60c36 (patch) | |
tree | 045adc46939d33e111ae62b404972557071ddfd4 /lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | 2627a881e1ba1c7821537d607dbd80c0ef4d2363 (diff) |
Perform obvious constant arithmetic folding.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63417 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index e507b893bc..d639ec018e 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -485,9 +485,10 @@ SDValue DAGCombiner::ReassociateOps(unsigned Opc, DebugLoc DL, if (N0.getOpcode() == Opc && isa<ConstantSDNode>(N0.getOperand(1))) { if (isa<ConstantSDNode>(N1)) { // reassoc. (op (op x, c1), c2) -> (op x, (op c1, c2)) - SDValue OpNode = DAG.getNode(Opc, N1.getDebugLoc(), VT, - N0.getOperand(1), N1); - AddToWorkList(OpNode.getNode()); + SDValue OpNode = + DAG.FoldConstantArithmetic(Opc, VT, + cast<ConstantSDNode>(N0.getOperand(1)), + cast<ConstantSDNode>(N1)); return DAG.getNode(Opc, DL, VT, N0.getOperand(0), OpNode); } else if (N0.hasOneUse()) { // reassoc. (op (op x, c1), y) -> (op (op x, y), c1) iff x+c1 has one use @@ -501,9 +502,10 @@ SDValue DAGCombiner::ReassociateOps(unsigned Opc, DebugLoc DL, if (N1.getOpcode() == Opc && isa<ConstantSDNode>(N1.getOperand(1))) { if (isa<ConstantSDNode>(N0)) { // reassoc. (op c2, (op x, c1)) -> (op x, (op c1, c2)) - SDValue OpNode = DAG.getNode(Opc, N1.getDebugLoc(), VT, - N1.getOperand(1), N0); - AddToWorkList(OpNode.getNode()); + SDValue OpNode = + DAG.FoldConstantArithmetic(Opc, VT, + cast<ConstantSDNode>(N1.getOperand(1)), + cast<ConstantSDNode>(N0)); return DAG.getNode(Opc, DL, VT, N1.getOperand(0), OpNode); } else if (N1.hasOneUse()) { // reassoc. (op y, (op x, c1)) -> (op (op x, y), c1) iff x+c1 has one use |