From 17e9754dd476f7f317f2a62f50c37da35fb0c5bd Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Sat, 30 Apr 2016 01:59:28 +0000 Subject: [PATCH] [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. llvm-svn: 268152 --- llvm/lib/Target/PowerPC/PPCQPXLoadSplat.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Target/PowerPC/PPCQPXLoadSplat.cpp b/llvm/lib/Target/PowerPC/PPCQPXLoadSplat.cpp index 642b90e..816f05f 100644 --- a/llvm/lib/Target/PowerPC/PPCQPXLoadSplat.cpp +++ b/llvm/lib/Target/PowerPC/PPCQPXLoadSplat.cpp @@ -130,7 +130,15 @@ bool PPCQPXLoadSplat::runOnMachineFunction(MachineFunction &MF) { } } - 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; } -- 2.7.4