[PowerPC] Fix the PPCInstrInfo::getInstrLatency implementation
authorHal Finkel <hfinkel@anl.gov>
Tue, 14 Jul 2015 20:02:02 +0000 (20:02 +0000)
committerHal Finkel <hfinkel@anl.gov>
Tue, 14 Jul 2015 20:02:02 +0000 (20:02 +0000)
commit13141f04d3f42f5090d8970dc9db01b1d345f7c5
treeafee65b93da6e31bcc47d1fdd2658bffe99cb1ea
parentfb17afba61c1e997da21c28e38500fd38175fd6b
[PowerPC] Fix the PPCInstrInfo::getInstrLatency implementation

PowerPC uses itineraries to describe processor pipelines (and dispatch-group
restrictions for P7/P8 cores). Unfortunately, the target-independent
implementation of TII.getInstrLatency calls ItinData->getStageLatency, and that
looks for the largest cycle count in the pipeline for any given instruction.
This, however, yields the wrong answer for the PPC itineraries, because we
don't encode the full pipeline. Because the functional units are fully
pipelined, we only model the initial stages (there are no relevant hazards in
the later stages to model), and so the technique employed by getStageLatency
does not really work. Instead, we should take the maximum output operand
latency, and that's what PPCInstrInfo::getInstrLatency now does.

This caused some test-case churn, including two unfortunate side effects.
First, the new arrangement of copies we get from function parameters now
sometimes blocks VSX FMA mutation (a FIXME has been added to the code and the
test cases), and we have one significant test-suite regression:

SingleSource/Benchmarks/BenchmarkGame/spectral-norm
56.4185% +/- 18.9398%

In this benchmark we have a loop with a vectorized FP divide, and it with the
new scheduling both divides end up in the same dispatch group (which in this
case seems to cause a problem, although why is not exactly clear). The grouping
structure is hard to predict from the bottom of the loop, and there may not be
much we can do to fix this.

Very few other test-suite performance effects were really significant, but
almost all weakly favor this change. However, in light of the issues
highlighted above, I've left the old behavior available via a
command-line flag.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242188 91177308-0d34-0410-b5e6-96231b3b80d8
12 files changed:
lib/Target/PowerPC/PPCInstrInfo.cpp
lib/Target/PowerPC/PPCInstrInfo.h
lib/Target/PowerPC/PPCScheduleP7.td
lib/Target/PowerPC/PPCScheduleP8.td
lib/Target/PowerPC/PPCVSXFMAMutate.cpp
test/CodeGen/PowerPC/ppc-crbits-onoff.ll
test/CodeGen/PowerPC/ppc64-fastcc-fast-isel.ll
test/CodeGen/PowerPC/ppc64-fastcc.ll
test/CodeGen/PowerPC/sjlj.ll
test/CodeGen/PowerPC/tls-store2.ll
test/CodeGen/PowerPC/vsx-fma-m.ll
test/CodeGen/PowerPC/vsx-fma-sp.ll