diff options
author | Evan Cheng <evan.cheng@apple.com> | 2007-03-23 02:16:52 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2007-03-23 02:16:52 +0000 |
commit | a824e79f06bbad3fa5549bcaeef320e4949f243b (patch) | |
tree | 5a2509e2389eeca9931645c3448f7171b439d771 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | b722f2b110e18960f4bd222034f06b3be7cf4180 (diff) | |
download | bcm5719-llvm-a824e79f06bbad3fa5549bcaeef320e4949f243b.tar.gz bcm5719-llvm-a824e79f06bbad3fa5549bcaeef320e4949f243b.zip |
A couple of bug fixes for reducing load width xform:
1. Address offset is in bytes.
2. Make sure truncate node uses are replaced with new load.
llvm-svn: 35274
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 7574048bc4a..1aea2ed35f5 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -2017,8 +2017,11 @@ SDOperand DAGCombiner::visitSIGN_EXTEND(SDNode *N) { // fold (sext (truncate (srl (load x), c))) -> (sext (smaller load (x+c/n))) if (N0.getOpcode() == ISD::TRUNCATE) { SDOperand NarrowLoad = ReduceLoadWidth(N0.Val); - if (NarrowLoad.Val) - N0 = NarrowLoad; + if (NarrowLoad.Val) { + if (NarrowLoad.Val != N0.Val) + CombineTo(N0.Val, NarrowLoad); + return DAG.getNode(ISD::SIGN_EXTEND, VT, NarrowLoad); + } } // See if the value being truncated is already sign extended. If so, just @@ -2109,8 +2112,11 @@ SDOperand DAGCombiner::visitZERO_EXTEND(SDNode *N) { // fold (zext (truncate (srl (load x), c))) -> (zext (small load (x+c/n))) if (N0.getOpcode() == ISD::TRUNCATE) { SDOperand NarrowLoad = ReduceLoadWidth(N0.Val); - if (NarrowLoad.Val) - N0 = NarrowLoad; + if (NarrowLoad.Val) { + if (NarrowLoad.Val != N0.Val) + CombineTo(N0.Val, NarrowLoad); + return DAG.getNode(ISD::ZERO_EXTEND, VT, NarrowLoad); + } } // fold (zext (truncate x)) -> (and x, mask) @@ -2189,8 +2195,11 @@ SDOperand DAGCombiner::visitANY_EXTEND(SDNode *N) { // fold (aext (truncate (srl (load x), c))) -> (aext (small load (x+c/n))) if (N0.getOpcode() == ISD::TRUNCATE) { SDOperand NarrowLoad = ReduceLoadWidth(N0.Val); - if (NarrowLoad.Val) - N0 = NarrowLoad; + if (NarrowLoad.Val) { + if (NarrowLoad.Val != N0.Val) + CombineTo(N0.Val, NarrowLoad); + return DAG.getNode(ISD::ANY_EXTEND, VT, NarrowLoad); + } } // fold (aext (truncate x)) @@ -2278,7 +2287,7 @@ SDOperand DAGCombiner::ReduceLoadWidth(SDNode *N) { N0 = N0.getOperand(0); if (MVT::getSizeInBits(N0.getValueType()) <= EVTBits) return SDOperand(); - ShAmt /= EVTBits; + ShAmt /= 8; } } } |