[llvm] r268152 - [PowerPC/QPX] Fix the load/splat peephole with overlapping reads

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 29 18:59:28 PDT 2016


Author: hfinkel
Date: Fri Apr 29 20:59:28 2016
New Revision: 268152

URL: http://llvm.org/viewvc/llvm-project?rev=268152&view=rev
Log:
[PowerPC/QPX] Fix the load/splat peephole with overlapping reads

If, in between the splat and the load (which does an implicit splat), there is
a read of the splat register, then that register must have another earlier
definition. In that case, we can't replace the load's destination register with
the splat's destination register.

Unfortunately, I don't have a small or non-fragile test case.

Modified:
    llvm/trunk/lib/Target/PowerPC/PPCQPXLoadSplat.cpp

Modified: llvm/trunk/lib/Target/PowerPC/PPCQPXLoadSplat.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCQPXLoadSplat.cpp?rev=268152&r1=268151&r2=268152&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCQPXLoadSplat.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCQPXLoadSplat.cpp Fri Apr 29 20:59:28 2016
@@ -130,7 +130,15 @@ bool PPCQPXLoadSplat::runOnMachineFuncti
           }
         }
 
-        if (MI->modifiesRegister(SplatReg, TRI)) {
+	// If this instruction defines the splat register, then we cannot move
+	// the previous definition above it. If it reads from the splat
+	// register, then it must already be alive from some previous
+	// definition, and if the splat register is different from the source
+	// register, then this definition must not be the load for which we're
+	// searching.
+        if (MI->modifiesRegister(SplatReg, TRI) ||
+            (SrcReg != SplatReg &&
+             MI->readsRegister(SplatReg, TRI))) {
           SI = Splats.erase(SI);
           continue;
         }




More information about the llvm-commits mailing list