From: Nate Begeman Date: Sun, 21 Nov 2004 05:14:06 +0000 (+0000) Subject: Fix Shootout-C++/wc, which was broken by my recent changes to emit fewer X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=486ebfd7049a42682762cc25c368d1a9ce3aed7b;p=oota-llvm.git Fix Shootout-C++/wc, which was broken by my recent changes to emit fewer reg-reg copies. The necessary conditions for this bug are a GEP that is used outside the basic block in which it is defined, whose components other than the pointer are all constant zero, and where the use is selected before the definition (backwards branch to successsor block). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18084 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/PowerPC/PPC32ISelSimple.cpp b/lib/Target/PowerPC/PPC32ISelSimple.cpp index c4babe06147..83ace163939 100644 --- a/lib/Target/PowerPC/PPC32ISelSimple.cpp +++ b/lib/Target/PowerPC/PPC32ISelSimple.cpp @@ -3835,18 +3835,19 @@ void PPC32ISel::emitGEPOperation(MachineBasicBlock *MBB, unsigned TargetReg = getReg(GEPI, MBB, IP); unsigned basePtrReg = getReg(Src, MBB, IP); - if ((indexReg == 0) && remainder->isNullValue()) - RegMap[GEPI] = basePtrReg; - + if ((indexReg == 0) && remainder->isNullValue()) { + BuildMI(*MBB, IP, PPC::OR, 2, TargetReg).addReg(basePtrReg) + .addReg(basePtrReg); + return; + } if (!remainder->isNullValue()) { unsigned TmpReg = (indexReg == 0) ? TargetReg : makeAnotherReg(Type::IntTy); emitBinaryConstOperation(MBB, IP, basePtrReg, remainder, 0, TmpReg); basePtrReg = TmpReg; } - if (indexReg != 0) { + if (indexReg != 0) BuildMI(*MBB, IP, PPC::ADD, 2, TargetReg).addReg(indexReg) .addReg(basePtrReg); - } } /// visitAllocaInst - If this is a fixed size alloca, allocate space from the