summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-01-20 01:11:03 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-01-20 01:11:03 +0000
commite272b4ec173fa20540a069d745dfa605ce0b5e93 (patch)
treebd2951eb2efc374db46d00372584f97de46422df
parent027c18da98ed3a03f159d25d63f75cd2f2092762 (diff)
downloadbcm5719-llvm-e272b4ec173fa20540a069d745dfa605ce0b5e93.tar.gz
bcm5719-llvm-e272b4ec173fa20540a069d745dfa605ce0b5e93.zip
Prevent folding of a node with multiple uses if the node already folds a load!
Here is an example where the load ended up being done twice: %A = global uint 0 uint %test(uint %B, ubyte %C) { %tmp = load uint *%A; %X = shl uint %tmp, ubyte %C %Cv = sub ubyte 32, %C %Y = shr uint %B, ubyte %Cv %Z = or uint %Y, %X store uint %Z, uint* %A ret uint %Z } ==> subl $4, %esp movl %ebx, (%esp) movl 8(%esp), %edx movl A, %eax movb 12(%esp), %bl movb %bl, %cl shldl %cl, %edx, %eax movb %bl, %cl shldl %cl, %edx, A movl (%esp), %ebx addl $4, %esp ret llvm-svn: 25471
-rw-r--r--llvm/utils/TableGen/DAGISelEmitter.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/llvm/utils/TableGen/DAGISelEmitter.cpp b/llvm/utils/TableGen/DAGISelEmitter.cpp
index f9f5504f76c..466adec50ac 100644
--- a/llvm/utils/TableGen/DAGISelEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelEmitter.cpp
@@ -1907,18 +1907,21 @@ public:
// Emit code to load the child nodes and match their contents recursively.
unsigned OpNo = 0;
- bool HasChain = NodeHasProperty(N, SDNodeInfo::SDNPHasChain, ISE);
+ bool NodeHasChain = NodeHasProperty(N, SDNodeInfo::SDNPHasChain, ISE);
+ bool HasChain = PatternHasProperty(N, SDNodeInfo::SDNPHasChain, ISE);
if (HasChain) {
- OpNo = 1;
+ if (NodeHasChain)
+ OpNo = 1;
if (!isRoot) {
const SDNodeInfo &CInfo = ISE.getSDNodeInfo(N->getOperator());
OS << " if (!" << RootName << ".hasOneUse()) goto P"
<< PatternNo << "Fail; // Multiple uses of actual result?\n";
- OS << " if (CodeGenMap.count(" << RootName
- << ".getValue(" << CInfo.getNumResults() << "))) goto P"
- << PatternNo << "Fail; // Already selected for a chain use?\n";
+ if (NodeHasChain)
+ OS << " if (CodeGenMap.count(" << RootName
+ << ".getValue(" << CInfo.getNumResults() << "))) goto P"
+ << PatternNo << "Fail; // Already selected for a chain use?\n";
}
- if (!FoundChain) {
+ if (NodeHasChain && !FoundChain) {
OS << " SDOperand Chain = " << RootName << ".getOperand(0);\n";
FoundChain = true;
}
OpenPOWER on IntegriCloud