Index: lib/Target/X86/X86.td =================================================================== --- lib/Target/X86/X86.td +++ lib/Target/X86/X86.td @@ -302,6 +302,18 @@ "Intel Silvermont processors">; def ProcIntelGLM : SubtargetFeature<"glm", "X86ProcFamily", "IntelGLM", "Intel Goldmont processors">; +def ProcIntelHSW : SubtargetFeature<"haswell", "X86ProcFamily", + "IntelHaswell", "Intel Haswell processors">; +def ProcIntelBDW : SubtargetFeature<"broadwell", "X86ProcFamily", + "IntelBroadwell", "Intel Broadwell processors">; +def ProcIntelSKL : SubtargetFeature<"skylake", "X86ProcFamily", + "IntelSkylake", "Intel Skylake processors">; +def ProcIntelKNL : SubtargetFeature<"knl", "X86ProcFamily", + "IntelKNL", "Intel Knights Landing processors">; +def ProcIntelSKX : SubtargetFeature<"skx", "X86ProcFamily", + "IntelSKX", "Intel Skylake Server processors">; +def ProcIntelCNL : SubtargetFeature<"cannonlake", "X86ProcFamily", + "IntelCannonlake", "Intel Cannonlake processors">; class Proc Features> : ProcessorModel; @@ -555,11 +567,14 @@ ]>; class HaswellProc : ProcModel; + HSWFeatures.Value, [ + ProcIntelHSW + ]>; def : HaswellProc<"haswell">; def : HaswellProc<"core-avx2">; // Legacy alias. def BDWFeatures : ProcessorFeatures; @@ -579,12 +594,15 @@ // FIXME: define SKL model class SkylakeClientProc : ProcModel; + SKLFeatures.Value, [ + ProcIntelSKL + ]>; def : SkylakeClientProc<"skylake">; // FIXME: define KNL model class KnightsLandingProc : ProcModel : ProcModel; + SKXFeatures.Value, [ + ProcIntelSKX + ]>; def : SkylakeServerProc<"skylake-avx512">; def : SkylakeServerProc<"skx">; // Legacy alias. @@ -624,7 +644,9 @@ ]>; class CannonlakeProc : ProcModel; + CNLFeatures.Value, [ + ProcIntelCNL + ]>; def : CannonlakeProc<"cannonlake">; // AMD CPUs. Index: lib/Target/X86/X86Subtarget.h =================================================================== --- lib/Target/X86/X86Subtarget.h +++ lib/Target/X86/X86Subtarget.h @@ -61,7 +61,16 @@ }; enum X86ProcFamilyEnum { - Others, IntelAtom, IntelSLM, IntelGLM + Others, + IntelAtom, + IntelSLM, + IntelGLM, + IntelHaswell, + IntelBroadwell, + IntelSkylake, + IntelKNL, + IntelSKX, + IntelCannonlake }; /// X86 processor family: Intel Atom, and others @@ -336,6 +345,10 @@ /// True if compiling for 16-bit, false for 32-bit or 64-bit. bool In16BitMode; + /// Contains the Overhead of gather\scatter instructions + int GatherOverhead; + int ScatterOverhead; + X86SelectionDAGInfo TSInfo; // Ordering here is important. X86InstrInfo initializes X86RegisterInfo which // X86TargetLowering needs. @@ -478,6 +491,8 @@ bool isPMULLDSlow() const { return IsPMULLDSlow; } bool isUnalignedMem16Slow() const { return IsUAMem16Slow; } bool isUnalignedMem32Slow() const { return IsUAMem32Slow; } + int getGatherOverhead() const { return GatherOverhead; } + int getScatterOverhead() const { return ScatterOverhead; } bool hasSSEUnalignedMem() const { return HasSSEUnalignedMem; } bool hasCmpxchg16b() const { return HasCmpxchg16b; } bool useLeaForSP() const { return UseLeaForSP; } @@ -510,6 +525,9 @@ bool isXRaySupported() const override { return is64Bit(); } + X86ProcFamilyEnum getProcFamily() const { return X86ProcFamily; } + + /// TODO: to be removed later and replaced with suitable properties bool isAtom() const { return X86ProcFamily == IntelAtom; } bool isSLM() const { return X86ProcFamily == IntelSLM; } bool useSoftFloat() const { return UseSoftFloat; } Index: lib/Target/X86/X86Subtarget.cpp =================================================================== --- lib/Target/X86/X86Subtarget.cpp +++ lib/Target/X86/X86Subtarget.cpp @@ -283,6 +283,30 @@ else if (isTargetDarwin() || isTargetLinux() || isTargetSolaris() || isTargetKFreeBSD() || In64BitMode) stackAlignment = 16; + + switch(X86ProcFamily) { + case IntelSkylake: + GatherOverhead = 2; + ScatterOverhead = 1024; // not relevant for AVX2 + break; + case IntelSKX: + GatherOverhead = 2; + ScatterOverhead = 2; + break; + default: + // Currently picking high overheads for other targets in order not to be selected + // TODO: need to get uArch overheads for hsw\bdw + // FIXME: giving 1024 as a max int because it may overflow in the CM calucation causing a + // wrong desicion or negative values, maybe need to move to FP? + if (hasAVX512()) { + GatherOverhead = 2; + ScatterOverhead = 2; + } + else { + GatherOverhead = 1024; + ScatterOverhead = 1024; + } + } } void X86Subtarget::initializeEnvironment() { @@ -360,6 +384,9 @@ // FIXME: this is a known good value for Yonah. How about others? MaxInlineSizeThreshold = 128; UseSoftFloat = false; + X86ProcFamily = Others; + GatherOverhead = 1024; + ScatterOverhead = 1024; } X86Subtarget &X86Subtarget::initializeSubtargetDependencies(StringRef CPU,