summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-15 06:10:49 +0000
committerChris Lattner <sabre@nondot.org>2010-04-15 06:10:49 +0000
commit3245afdf05234f72721d95fd0cde097255d6814f (patch)
treebfa70cf9b11f49d5aa5ee83a5762e1defac6f869 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parent76fa840d0990314d1d1c160803ba9d014a6c01a9 (diff)
downloadbcm5719-llvm-3245afdf05234f72721d95fd0cde097255d6814f.tar.gz
bcm5719-llvm-3245afdf05234f72721d95fd0cde097255d6814f.zip
enhance the load/store narrowing optimization to handle a
tokenfactor in between the load/store. This allows us to optimize test7 into: _test7: ## @test7 ## BB#0: ## %entry movl (%rdx), %eax ## kill: SIL<def> ESI<kill> movb %sil, 5(%rdi) ret instead of: _test7: ## @test7 ## BB#0: ## %entry movl 4(%esp), %ecx movl $-65281, %eax ## imm = 0xFFFFFFFFFFFF00FF andl 4(%ecx), %eax movzbl 8(%esp), %edx shll $8, %edx addl %eax, %edx movl 12(%esp), %eax movl (%eax), %eax movl %edx, 4(%ecx) ret llvm-svn: 101355
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 69a26169053..ec70a5ed572 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -5172,12 +5172,25 @@ CheckForMaskedLoad(SDValue V, SDValue Ptr, SDValue Chain) {
!ISD::isNormalLoad(V->getOperand(0).getNode()))
return Result;
- // Check the chain and pointer. The store should be chained directly to the
- // load (TODO: Or through a TF node!) since it's to the same address.
+ // Check the chain and pointer.
LoadSDNode *LD = cast<LoadSDNode>(V->getOperand(0));
- if (LD->getBasePtr() != Ptr ||
- V->getOperand(0).getNode() != Chain.getNode())
- return Result;
+ if (LD->getBasePtr() != Ptr) return Result; // Not from same pointer.
+
+ // The store should be chained directly to the load or be an operand of a
+ // tokenfactor.
+ if (LD == Chain.getNode())
+ ; // ok.
+ else if (Chain->getOpcode() != ISD::TokenFactor)
+ return Result; // Fail.
+ else {
+ bool isOk = false;
+ for (unsigned i = 0, e = Chain->getNumOperands(); i != e; ++i)
+ if (Chain->getOperand(i).getNode() == LD) {
+ isOk = true;
+ break;
+ }
+ if (!isOk) return Result;
+ }
// This only handles simple types.
if (V.getValueType() != MVT::i16 &&
OpenPOWER on IntegriCloud