2012-02-18 12:03:15 +00:00
|
|
|
//===-- PowerPCSubtarget.cpp - PPC Subtarget Information ------------------===//
|
2005-08-04 07:12:09 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-08-04 07:12:09 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2011-07-01 21:01:15 +00:00
|
|
|
// This file implements the PPC specific subclass of TargetSubtargetInfo.
|
2005-08-04 07:12:09 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2005-10-14 23:51:18 +00:00
|
|
|
#include "PPCSubtarget.h"
|
|
|
|
#include "PPC.h"
|
2012-12-03 16:50:05 +00:00
|
|
|
#include "PPCRegisterInfo.h"
|
2013-07-15 22:29:40 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2013-09-11 23:05:25 +00:00
|
|
|
#include "llvm/CodeGen/MachineScheduler.h"
|
2013-07-15 22:29:40 +00:00
|
|
|
#include "llvm/IR/Attributes.h"
|
|
|
|
#include "llvm/IR/Function.h"
|
2014-01-07 11:48:04 +00:00
|
|
|
#include "llvm/IR/GlobalValue.h"
|
2012-06-12 03:03:13 +00:00
|
|
|
#include "llvm/Support/Host.h"
|
2011-08-24 18:08:43 +00:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
2012-12-03 16:50:05 +00:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2009-01-05 17:59:02 +00:00
|
|
|
#include <cstdlib>
|
2011-07-01 20:45:01 +00:00
|
|
|
|
2014-04-22 02:03:14 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2014-04-21 22:55:11 +00:00
|
|
|
#define DEBUG_TYPE "ppc-subtarget"
|
|
|
|
|
2011-07-01 20:45:01 +00:00
|
|
|
#define GET_SUBTARGETINFO_TARGET_DESC
|
2011-07-08 01:53:10 +00:00
|
|
|
#define GET_SUBTARGETINFO_CTOR
|
2011-07-01 22:36:09 +00:00
|
|
|
#include "PPCGenSubtargetInfo.inc"
|
2011-07-01 20:45:01 +00:00
|
|
|
|
2014-06-12 21:08:06 +00:00
|
|
|
/// Return the datalayout string of a subtarget.
|
|
|
|
static std::string getDataLayoutString(const PPCSubtarget &ST) {
|
|
|
|
const Triple &T = ST.getTargetTriple();
|
|
|
|
|
|
|
|
std::string Ret;
|
|
|
|
|
|
|
|
// Most PPC* platforms are big endian, PPC64LE is little endian.
|
|
|
|
if (ST.isLittleEndian())
|
|
|
|
Ret = "e";
|
|
|
|
else
|
|
|
|
Ret = "E";
|
|
|
|
|
|
|
|
Ret += DataLayout::getManglingComponent(T);
|
|
|
|
|
|
|
|
// PPC32 has 32 bit pointers. The PS3 (OS Lv2) is a PPC64 machine with 32 bit
|
|
|
|
// pointers.
|
|
|
|
if (!ST.isPPC64() || T.getOS() == Triple::Lv2)
|
|
|
|
Ret += "-p:32:32";
|
|
|
|
|
|
|
|
// Note, the alignment values for f64 and i64 on ppc64 in Darwin
|
|
|
|
// documentation are wrong; these are correct (i.e. "what gcc does").
|
|
|
|
if (ST.isPPC64() || ST.isSVR4ABI())
|
|
|
|
Ret += "-i64:64";
|
|
|
|
else
|
|
|
|
Ret += "-f64:32:64";
|
|
|
|
|
|
|
|
// PPC64 has 32 and 64 bit registers, PPC32 has only 32 bit ones.
|
|
|
|
if (ST.isPPC64())
|
|
|
|
Ret += "-n32:64";
|
|
|
|
else
|
|
|
|
Ret += "-n32";
|
|
|
|
|
|
|
|
return Ret;
|
|
|
|
}
|
|
|
|
|
2014-06-12 20:54:11 +00:00
|
|
|
PPCSubtarget &PPCSubtarget::initializeSubtargetDependencies(StringRef CPU,
|
|
|
|
StringRef FS) {
|
|
|
|
initializeEnvironment();
|
|
|
|
resetSubtargetFeatures(CPU, FS);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2011-06-30 01:53:36 +00:00
|
|
|
PPCSubtarget::PPCSubtarget(const std::string &TT, const std::string &CPU,
|
2014-06-12 22:50:10 +00:00
|
|
|
const std::string &FS, PPCTargetMachine &TM,
|
|
|
|
bool is64Bit, CodeGenOpt::Level OptLevel)
|
2014-05-13 20:49:08 +00:00
|
|
|
: PPCGenSubtargetInfo(TT, CPU, FS), IsPPC64(is64Bit), TargetTriple(TT),
|
2014-06-12 20:54:11 +00:00
|
|
|
OptLevel(OptLevel),
|
2014-06-12 21:08:06 +00:00
|
|
|
FrameLowering(initializeSubtargetDependencies(CPU, FS)),
|
2014-06-12 22:50:10 +00:00
|
|
|
DL(getDataLayoutString(*this)), InstrInfo(*this), JITInfo(*this),
|
2014-06-12 23:02:32 +00:00
|
|
|
TLInfo(TM), TSInfo(&DL) {}
|
2013-07-15 22:29:40 +00:00
|
|
|
|
|
|
|
/// SetJITMode - This is called to inform the subtarget info that we are
|
|
|
|
/// producing code for the JIT.
|
|
|
|
void PPCSubtarget::SetJITMode() {
|
|
|
|
// JIT mode doesn't want lazy resolver stubs, it knows exactly where
|
|
|
|
// everything is. This matters for PPC64, which codegens in PIC mode without
|
|
|
|
// stubs.
|
|
|
|
HasLazyResolverStubs = false;
|
|
|
|
|
|
|
|
// Calls to external functions need to use indirect calls
|
|
|
|
IsJITCodeModel = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PPCSubtarget::resetSubtargetFeatures(const MachineFunction *MF) {
|
|
|
|
AttributeSet FnAttrs = MF->getFunction()->getAttributes();
|
|
|
|
Attribute CPUAttr = FnAttrs.getAttribute(AttributeSet::FunctionIndex,
|
|
|
|
"target-cpu");
|
|
|
|
Attribute FSAttr = FnAttrs.getAttribute(AttributeSet::FunctionIndex,
|
|
|
|
"target-features");
|
|
|
|
std::string CPU =
|
|
|
|
!CPUAttr.hasAttribute(Attribute::None) ? CPUAttr.getValueAsString() : "";
|
|
|
|
std::string FS =
|
|
|
|
!FSAttr.hasAttribute(Attribute::None) ? FSAttr.getValueAsString() : "";
|
|
|
|
if (!FS.empty()) {
|
|
|
|
initializeEnvironment();
|
|
|
|
resetSubtargetFeatures(CPU, FS);
|
|
|
|
}
|
|
|
|
}
|
2005-08-05 22:05:03 +00:00
|
|
|
|
2013-07-15 22:29:40 +00:00
|
|
|
void PPCSubtarget::initializeEnvironment() {
|
|
|
|
StackAlignment = 16;
|
|
|
|
DarwinDirective = PPC::DIR_NONE;
|
|
|
|
HasMFOCRF = false;
|
|
|
|
Has64BitSupport = false;
|
|
|
|
Use64BitRegs = false;
|
Add CR-bit tracking to the PowerPC backend for i1 values
This change enables tracking i1 values in the PowerPC backend using the
condition register bits. These bits can be treated on PowerPC as separate
registers; individual bit operations (and, or, xor, etc.) are supported.
Tracking booleans in CR bits has several advantages:
- Reduction in register pressure (because we no longer need GPRs to store
boolean values).
- Logical operations on booleans can be handled more efficiently; we used to
have to move all results from comparisons into GPRs, perform promoted
logical operations in GPRs, and then move the result back into condition
register bits to be used by conditional branches. This can be very
inefficient, because the throughput of these CR <-> GPR moves have high
latency and low throughput (especially when other associated instructions
are accounted for).
- On the POWER7 and similar cores, we can increase total throughput by using
the CR bits. CR bit operations have a dedicated functional unit.
Most of this is more-or-less mechanical: Adjustments were needed in the
calling-convention code, support was added for spilling/restoring individual
condition-register bits, and conditional branch instruction definitions taking
specific CR bits were added (plus patterns and code for generating bit-level
operations).
This is enabled by default when running at -O2 and higher. For -O0 and -O1,
where the ability to debug is more important, this feature is disabled by
default. Individual CR bits do not have assigned DWARF register numbers,
and storing values in CR bits makes them invisible to the debugger.
It is critical, however, that we don't move i1 values that have been promoted
to larger values (such as those passed as function arguments) into bit
registers only to quickly turn around and move the values back into GPRs (such
as happens when values are returned by functions). A pair of target-specific
DAG combines are added to remove the trunc/extends in:
trunc(binary-ops(binary-ops(zext(x), zext(y)), ...)
and:
zext(binary-ops(binary-ops(trunc(x), trunc(y)), ...)
In short, we only want to use CR bits where some of the i1 values come from
comparisons or are used by conditional branches or selects. To put it another
way, if we can do the entire i1 computation in GPRs, then we probably should
(on the POWER7, the GPR-operation throughput is higher, and for all cores, the
CR <-> GPR moves are expensive).
POWER7 test-suite performance results (from 10 runs in each configuration):
SingleSource/Benchmarks/Misc/mandel-2: 35% speedup
MultiSource/Benchmarks/Prolangs-C++/city/city: 21% speedup
MultiSource/Benchmarks/MiBench/automotive-susan: 23% speedup
SingleSource/Benchmarks/CoyoteBench/huffbench: 13% speedup
SingleSource/Benchmarks/Misc-C++/Large/sphereflake: 13% speedup
SingleSource/Benchmarks/Misc-C++/mandel-text: 10% speedup
SingleSource/Benchmarks/Misc-C++-EH/spirit: 10% slowdown
MultiSource/Applications/lemon/lemon: 8% slowdown
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202451 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-28 00:27:01 +00:00
|
|
|
UseCRBits = false;
|
2013-07-15 22:29:40 +00:00
|
|
|
HasAltivec = false;
|
|
|
|
HasQPX = false;
|
[PowerPC] Initial support for the VSX instruction set
VSX is an ISA extension supported on the POWER7 and later cores that enhances
floating-point vector and scalar capabilities. Among other things, this adds
<2 x double> support and generally helps to reduce register pressure.
The interesting part of this ISA feature is the register configuration: there
are 64 new 128-bit vector registers, the 32 of which are super-registers of the
existing 32 scalar floating-point registers, and the second 32 of which overlap
with the 32 Altivec vector registers. This makes things like vector insertion
and extraction tricky: this can be free but only if we force a restriction to
the right register subclass when needed. A new "minipass" PPCVSXCopy takes care
of this (although it could do a more-optimal job of it; see the comment about
unnecessary copies below).
Please note that, currently, VSX is not enabled by default when targeting
anything because it is not yet ready for that. The assembler and disassembler
are fully implemented and tested. However:
- CodeGen support causes miscompiles; test-suite runtime failures:
MultiSource/Benchmarks/FreeBench/distray/distray
MultiSource/Benchmarks/McCat/08-main/main
MultiSource/Benchmarks/Olden/voronoi/voronoi
MultiSource/Benchmarks/mafft/pairlocalalign
MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4
SingleSource/Benchmarks/CoyoteBench/almabench
SingleSource/Benchmarks/Misc/matmul_f64_4x4
- The lowering currently falls back to using Altivec instructions far more
than it should. Worse, there are some things that are scalarized through the
stack that shouldn't be.
- A lot of unnecessary copies make it past the optimizers, and this needs to
be fixed.
- Many more regression tests are needed.
Normally, I'd fix these things prior to committing, but there are some
students and other contributors who would like to work this, and so it makes
sense to move this development process upstream where it can be subject to the
regular code-review procedures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203768 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-13 07:58:58 +00:00
|
|
|
HasVSX = false;
|
2013-08-19 05:01:02 +00:00
|
|
|
HasFCPSGN = false;
|
2013-07-15 22:29:40 +00:00
|
|
|
HasFSQRT = false;
|
|
|
|
HasFRE = false;
|
|
|
|
HasFRES = false;
|
|
|
|
HasFRSQRTE = false;
|
|
|
|
HasFRSQRTES = false;
|
|
|
|
HasRecipPrec = false;
|
|
|
|
HasSTFIWX = false;
|
|
|
|
HasLFIWAX = false;
|
|
|
|
HasFPRND = false;
|
|
|
|
HasFPCVT = false;
|
|
|
|
HasISEL = false;
|
|
|
|
HasPOPCNTD = false;
|
|
|
|
HasLDBRX = false;
|
|
|
|
IsBookE = false;
|
2013-09-12 14:40:06 +00:00
|
|
|
DeprecatedMFTB = false;
|
|
|
|
DeprecatedDST = false;
|
2013-07-15 22:29:40 +00:00
|
|
|
HasLazyResolverStubs = false;
|
|
|
|
IsJITCodeModel = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PPCSubtarget::resetSubtargetFeatures(StringRef CPU, StringRef FS) {
|
2005-09-01 21:38:21 +00:00
|
|
|
// Determine default and user specified characteristics
|
2011-06-30 01:53:36 +00:00
|
|
|
std::string CPUName = CPU;
|
|
|
|
if (CPUName.empty())
|
|
|
|
CPUName = "generic";
|
2012-06-12 03:03:13 +00:00
|
|
|
#if (defined(__APPLE__) || defined(__linux__)) && \
|
|
|
|
(defined(__ppc__) || defined(__powerpc__))
|
2011-06-30 01:53:36 +00:00
|
|
|
if (CPUName == "generic")
|
2012-06-12 03:03:13 +00:00
|
|
|
CPUName = sys::getHostCPUName();
|
2005-09-01 21:38:21 +00:00
|
|
|
#endif
|
2005-10-26 17:30:34 +00:00
|
|
|
|
2011-07-01 20:45:01 +00:00
|
|
|
// Initialize scheduling itinerary for the specified CPU.
|
|
|
|
InstrItins = getInstrItineraryForCPU(CPUName);
|
|
|
|
|
2012-10-25 12:27:42 +00:00
|
|
|
// Make sure 64-bit features are available when CPUname is generic
|
|
|
|
std::string FullFS = FS;
|
|
|
|
|
2006-06-16 17:50:12 +00:00
|
|
|
// If we are generating code for ppc64, verify that options make sense.
|
2013-07-15 22:29:40 +00:00
|
|
|
if (IsPPC64) {
|
2008-02-15 18:40:53 +00:00
|
|
|
Has64BitSupport = true;
|
2006-06-16 20:05:06 +00:00
|
|
|
// Silently force 64-bit register use on ppc64.
|
|
|
|
Use64BitRegs = true;
|
2012-10-25 12:27:42 +00:00
|
|
|
if (!FullFS.empty())
|
|
|
|
FullFS = "+64bit," + FullFS;
|
|
|
|
else
|
|
|
|
FullFS = "+64bit";
|
2006-06-16 17:50:12 +00:00
|
|
|
}
|
2012-10-04 16:20:24 +00:00
|
|
|
|
2014-05-13 20:49:08 +00:00
|
|
|
// At -O2 and above, track CR bits as individual registers.
|
|
|
|
if (OptLevel >= CodeGenOpt::Default) {
|
|
|
|
if (!FullFS.empty())
|
|
|
|
FullFS = "+crbits," + FullFS;
|
|
|
|
else
|
|
|
|
FullFS = "+crbits";
|
|
|
|
}
|
|
|
|
|
2012-10-25 12:27:42 +00:00
|
|
|
// Parse features string.
|
|
|
|
ParseSubtargetFeatures(CPUName, FullFS);
|
|
|
|
|
2006-06-16 17:50:12 +00:00
|
|
|
// If the user requested use of 64-bit regs, but the cpu selected doesn't
|
2008-02-15 18:40:53 +00:00
|
|
|
// support it, ignore.
|
|
|
|
if (use64BitRegs() && !has64BitSupport())
|
2006-06-16 17:50:12 +00:00
|
|
|
Use64BitRegs = false;
|
2006-12-11 23:22:45 +00:00
|
|
|
|
|
|
|
// Set up darwin-specific properties.
|
2009-08-11 22:49:34 +00:00
|
|
|
if (isDarwin())
|
2006-12-11 23:22:45 +00:00
|
|
|
HasLazyResolverStubs = true;
|
2013-01-30 23:43:27 +00:00
|
|
|
|
|
|
|
// QPX requires a 32-byte aligned stack. Note that we need to do this if
|
|
|
|
// we're compiling for a BG/Q system regardless of whether or not QPX
|
|
|
|
// is enabled because external functions will assume this alignment.
|
|
|
|
if (hasQPX() || isBGQ())
|
|
|
|
StackAlignment = 32;
|
2013-07-26 01:35:43 +00:00
|
|
|
|
|
|
|
// Determine endianness.
|
|
|
|
IsLittleEndian = (TargetTriple.getArch() == Triple::ppc64le);
|
2014-06-05 16:21:13 +00:00
|
|
|
|
|
|
|
// FIXME: For now, we disable VSX in little-endian mode until endian
|
|
|
|
// issues in those instructions can be addressed.
|
|
|
|
if (IsLittleEndian)
|
|
|
|
HasVSX = false;
|
2006-12-11 23:22:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// hasLazyResolverStub - Return true if accesses to the specified global have
|
|
|
|
/// to go through a dyld lazy resolution stub. This means that an extra load
|
|
|
|
/// is required to get the address of the global.
|
2009-08-02 22:11:08 +00:00
|
|
|
bool PPCSubtarget::hasLazyResolverStub(const GlobalValue *GV,
|
|
|
|
const TargetMachine &TM) const {
|
2010-11-15 02:46:57 +00:00
|
|
|
// We never have stubs if HasLazyResolverStubs=false or if in static mode.
|
2006-12-11 23:22:45 +00:00
|
|
|
if (!HasLazyResolverStubs || TM.getRelocationModel() == Reloc::Static)
|
|
|
|
return false;
|
2008-12-05 01:06:39 +00:00
|
|
|
// If symbol visibility is hidden, the extra load is not needed if
|
|
|
|
// the symbol is definitely defined in the current translation unit.
|
2010-01-27 20:34:15 +00:00
|
|
|
bool isDecl = GV->isDeclaration() && !GV->isMaterializable();
|
2008-12-05 01:06:39 +00:00
|
|
|
if (GV->hasHiddenVisibility() && !isDecl && !GV->hasCommonLinkage())
|
|
|
|
return false;
|
2006-12-11 23:22:45 +00:00
|
|
|
return GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
|
2008-12-05 01:06:39 +00:00
|
|
|
GV->hasCommonLinkage() || isDecl;
|
2005-08-04 07:12:09 +00:00
|
|
|
}
|
2011-12-02 04:58:02 +00:00
|
|
|
|
|
|
|
bool PPCSubtarget::enablePostRAScheduler(
|
|
|
|
CodeGenOpt::Level OptLevel,
|
|
|
|
TargetSubtargetInfo::AntiDepBreakMode& Mode,
|
|
|
|
RegClassVector& CriticalPathRCs) const {
|
2013-09-12 05:24:49 +00:00
|
|
|
Mode = TargetSubtargetInfo::ANTIDEP_ALL;
|
2011-12-02 04:58:02 +00:00
|
|
|
|
|
|
|
CriticalPathRCs.clear();
|
|
|
|
|
|
|
|
if (isPPC64())
|
|
|
|
CriticalPathRCs.push_back(&PPC::G8RCRegClass);
|
|
|
|
else
|
|
|
|
CriticalPathRCs.push_back(&PPC::GPRCRegClass);
|
2012-06-10 11:15:36 +00:00
|
|
|
|
2011-12-02 04:58:02 +00:00
|
|
|
return OptLevel >= CodeGenOpt::Default;
|
|
|
|
}
|
|
|
|
|
Add a scheduling model (with itinerary) for the PPC POWER7
This adds a scheduling model for the POWER7 (P7) core, and enables the
machine-instruction scheduler when targeting the P7. Scheduling for the P7,
like earlier ooo PPC cores, requires considering both dispatch group hazards,
and functional unit resources and latencies. These are both modeled in a
combined itinerary. Dispatch group formation is still handled by the post-RA
scheduler (which still needs to be updated for the P7, but nevertheless does a
pretty good job).
One interesting aspect of this change is that I've also enabled to use of AA
duing CodeGen for the P7 (just as it is for the embedded cores). The benchmark
results seem to support this decision (see below), and while this is normally
useful for in-order cores, and not for ooo cores like the P7, I think that the
dispatch slot hazards are enough like in-order resources to make the AA useful.
Test suite significant performance differences (where negative is a speedup,
and positive is a regression) vs. the current situation:
MultiSource/Benchmarks/BitBench/drop3/drop3
with AA: N/A
without AA: -28.7614% +/- 19.8356%
(significantly against AA)
MultiSource/Benchmarks/FreeBench/neural/neural
with AA: -17.7406% +/- 11.2712%
without AA: N/A
(significantly in favor of AA)
MultiSource/Benchmarks/SciMark2-C/scimark2
with AA: -11.2079% +/- 1.80543%
without AA: -11.3263% +/- 2.79651%
MultiSource/Benchmarks/TSVC/Symbolics-flt/Symbolics-flt
with AA: -41.8649% +/- 17.0053%
without AA: -34.5256% +/- 23.7072%
MultiSource/Benchmarks/mafft/pairlocalalign
with AA: 25.3016% +/- 17.8614%
without AA: 38.6629% +/- 14.9391%
(significantly in favor of AA)
MultiSource/Benchmarks/sim/sim
with AA: N/A
without AA: 13.4844% +/- 7.18195%
(significantly in favor of AA)
SingleSource/Benchmarks/BenchmarkGame/Large/fasta
with AA: 15.0664% +/- 6.70216%
without AA: 12.7747% +/- 8.43043%
SingleSource/Benchmarks/BenchmarkGame/puzzle
with AA: 82.2713% +/- 26.3567%
without AA: 75.7525% +/- 41.1842%
SingleSource/Benchmarks/Misc/flops-2
with AA: -37.1621% +/- 20.7964%
without AA: -35.2342% +/- 20.2999%
(significantly in favor of AA)
These are 99.5% confidence intervals from 5 runs per configuration. Regarding
the choice to turn on AA during CodeGen, of these results, four seem
significantly in favor of using AA, and one seems significantly against. I'm
not making this decision based on these numbers alone, but these results
seem consistent with results I have from other tests, and so I think that, on
balance, using AA is a win.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195981 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-30 20:55:12 +00:00
|
|
|
// Embedded cores need aggressive scheduling (and some others also benefit).
|
2013-09-11 23:05:25 +00:00
|
|
|
static bool needsAggressiveScheduling(unsigned Directive) {
|
|
|
|
switch (Directive) {
|
|
|
|
default: return false;
|
|
|
|
case PPC::DIR_440:
|
|
|
|
case PPC::DIR_A2:
|
|
|
|
case PPC::DIR_E500mc:
|
|
|
|
case PPC::DIR_E5500:
|
Add a scheduling model (with itinerary) for the PPC POWER7
This adds a scheduling model for the POWER7 (P7) core, and enables the
machine-instruction scheduler when targeting the P7. Scheduling for the P7,
like earlier ooo PPC cores, requires considering both dispatch group hazards,
and functional unit resources and latencies. These are both modeled in a
combined itinerary. Dispatch group formation is still handled by the post-RA
scheduler (which still needs to be updated for the P7, but nevertheless does a
pretty good job).
One interesting aspect of this change is that I've also enabled to use of AA
duing CodeGen for the P7 (just as it is for the embedded cores). The benchmark
results seem to support this decision (see below), and while this is normally
useful for in-order cores, and not for ooo cores like the P7, I think that the
dispatch slot hazards are enough like in-order resources to make the AA useful.
Test suite significant performance differences (where negative is a speedup,
and positive is a regression) vs. the current situation:
MultiSource/Benchmarks/BitBench/drop3/drop3
with AA: N/A
without AA: -28.7614% +/- 19.8356%
(significantly against AA)
MultiSource/Benchmarks/FreeBench/neural/neural
with AA: -17.7406% +/- 11.2712%
without AA: N/A
(significantly in favor of AA)
MultiSource/Benchmarks/SciMark2-C/scimark2
with AA: -11.2079% +/- 1.80543%
without AA: -11.3263% +/- 2.79651%
MultiSource/Benchmarks/TSVC/Symbolics-flt/Symbolics-flt
with AA: -41.8649% +/- 17.0053%
without AA: -34.5256% +/- 23.7072%
MultiSource/Benchmarks/mafft/pairlocalalign
with AA: 25.3016% +/- 17.8614%
without AA: 38.6629% +/- 14.9391%
(significantly in favor of AA)
MultiSource/Benchmarks/sim/sim
with AA: N/A
without AA: 13.4844% +/- 7.18195%
(significantly in favor of AA)
SingleSource/Benchmarks/BenchmarkGame/Large/fasta
with AA: 15.0664% +/- 6.70216%
without AA: 12.7747% +/- 8.43043%
SingleSource/Benchmarks/BenchmarkGame/puzzle
with AA: 82.2713% +/- 26.3567%
without AA: 75.7525% +/- 41.1842%
SingleSource/Benchmarks/Misc/flops-2
with AA: -37.1621% +/- 20.7964%
without AA: -35.2342% +/- 20.2999%
(significantly in favor of AA)
These are 99.5% confidence intervals from 5 runs per configuration. Regarding
the choice to turn on AA during CodeGen, of these results, four seem
significantly in favor of using AA, and one seems significantly against. I'm
not making this decision based on these numbers alone, but these results
seem consistent with results I have from other tests, and so I think that, on
balance, using AA is a win.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195981 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-30 20:55:12 +00:00
|
|
|
case PPC::DIR_PWR7:
|
2014-06-26 13:36:19 +00:00
|
|
|
case PPC::DIR_PWR8:
|
2013-09-11 23:05:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PPCSubtarget::enableMachineScheduler() const {
|
|
|
|
// Enable MI scheduling for the embedded cores.
|
|
|
|
// FIXME: Enable this for all cores (some additional modeling
|
|
|
|
// may be necessary).
|
|
|
|
return needsAggressiveScheduling(DarwinDirective);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PPCSubtarget::overrideSchedPolicy(MachineSchedPolicy &Policy,
|
|
|
|
MachineInstr *begin,
|
|
|
|
MachineInstr *end,
|
|
|
|
unsigned NumRegionInstrs) const {
|
|
|
|
if (needsAggressiveScheduling(DarwinDirective)) {
|
|
|
|
Policy.OnlyTopDown = false;
|
|
|
|
Policy.OnlyBottomUp = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Spilling is generally expensive on all PPC cores, so always enable
|
|
|
|
// register-pressure tracking.
|
|
|
|
Policy.ShouldTrackPressure = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PPCSubtarget::useAA() const {
|
|
|
|
// Use AA during code generation for the embedded cores.
|
|
|
|
return needsAggressiveScheduling(DarwinDirective);
|
|
|
|
}
|
|
|
|
|