[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Evan Cheng
evan.cheng at apple.com
Thu Mar 22 19:18:32 PDT 2007
Changes in directory llvm/lib/CodeGen/SelectionDAG:
DAGCombiner.cpp updated: 1.277 -> 1.278
---
Log message:
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.
---
Diffs of the changes: (+16 -7)
DAGCombiner.cpp | 23 ++++++++++++++++-------
1 files changed, 16 insertions(+), 7 deletions(-)
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.277 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.278
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1.277 Wed Mar 21 20:54:19 2007
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Thu Mar 22 21:16:52 2007
@@ -2017,8 +2017,11 @@
// 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 @@
// 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 @@
// 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 @@
N0 = N0.getOperand(0);
if (MVT::getSizeInBits(N0.getValueType()) <= EVTBits)
return SDOperand();
- ShAmt /= EVTBits;
+ ShAmt /= 8;
}
}
}
More information about the llvm-commits
mailing list