[llvm] r261584 - [X86] Create mergeable constant pool entries for AVX
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 22 14:23:11 PST 2016
Author: majnemer
Date: Mon Feb 22 16:23:11 2016
New Revision: 261584
URL: http://llvm.org/viewvc/llvm-project?rev=261584&view=rev
Log:
[X86] Create mergeable constant pool entries for AVX
We supported creating mergeable constant pool entries for smaller
constants but not for 32-byte AVX constants.
Modified:
llvm/trunk/include/llvm/MC/MCObjectFileInfo.h
llvm/trunk/include/llvm/MC/SectionKind.h
llvm/trunk/lib/CodeGen/MachineFunction.cpp
llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/trunk/lib/MC/MCObjectFileInfo.cpp
llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp
llvm/trunk/test/CodeGen/X86/global-sections.ll
llvm/trunk/test/CodeGen/X86/win_cst_pool.ll
Modified: llvm/trunk/include/llvm/MC/MCObjectFileInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectFileInfo.h?rev=261584&r1=261583&r2=261584&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCObjectFileInfo.h (original)
+++ llvm/trunk/include/llvm/MC/MCObjectFileInfo.h Mon Feb 22 16:23:11 2016
@@ -159,6 +159,7 @@ protected:
MCSection *MergeableConst4Section;
MCSection *MergeableConst8Section;
MCSection *MergeableConst16Section;
+ MCSection *MergeableConst32Section;
// MachO specific sections.
@@ -298,6 +299,9 @@ public:
const MCSection *getMergeableConst16Section() const {
return MergeableConst16Section;
}
+ const MCSection *getMergeableConst32Section() const {
+ return MergeableConst32Section;
+ }
// MachO specific sections.
const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
Modified: llvm/trunk/include/llvm/MC/SectionKind.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/SectionKind.h?rev=261584&r1=261583&r2=261584&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/SectionKind.h (original)
+++ llvm/trunk/include/llvm/MC/SectionKind.h Mon Feb 22 16:23:11 2016
@@ -63,6 +63,10 @@ class SectionKind {
/// for example, vectors.
MergeableConst16,
+ /// MergeableConst32 - This is a section used by 32-byte constants,
+ /// for example, vectors.
+ MergeableConst32,
+
/// Writeable - This is the base of all segments that need to be written
/// to during program runtime.
@@ -125,11 +129,12 @@ public:
bool isMergeableConst() const {
return K == MergeableConst4 || K == MergeableConst8 ||
- K == MergeableConst16;
+ K == MergeableConst16 || K == MergeableConst32;
}
bool isMergeableConst4() const { return K == MergeableConst4; }
bool isMergeableConst8() const { return K == MergeableConst8; }
bool isMergeableConst16() const { return K == MergeableConst16; }
+ bool isMergeableConst32() const { return K == MergeableConst32; }
bool isWriteable() const {
return isThreadLocal() || isGlobalWriteableData();
@@ -180,6 +185,7 @@ public:
static SectionKind getMergeableConst4() { return get(MergeableConst4); }
static SectionKind getMergeableConst8() { return get(MergeableConst8); }
static SectionKind getMergeableConst16() { return get(MergeableConst16); }
+ static SectionKind getMergeableConst32() { return get(MergeableConst32); }
static SectionKind getThreadBSS() { return get(ThreadBSS); }
static SectionKind getThreadData() { return get(ThreadData); }
static SectionKind getBSS() { return get(BSS); }
Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=261584&r1=261583&r2=261584&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Mon Feb 22 16:23:11 2016
@@ -852,6 +852,8 @@ MachineConstantPoolEntry::getSectionKind
return SectionKind::getMergeableConst8();
case 16:
return SectionKind::getMergeableConst16();
+ case 32:
+ return SectionKind::getMergeableConst32();
default:
return SectionKind::getReadOnly();
}
Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=261584&r1=261583&r2=261584&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Mon Feb 22 16:23:11 2016
@@ -270,9 +270,11 @@ selectELFSectionForGlobal(MCContext &Ctx
EntrySize = 4;
} else if (Kind.isMergeableConst8()) {
EntrySize = 8;
- } else {
- assert(Kind.isMergeableConst16() && "unknown data width");
+ } else if (Kind.isMergeableConst16()) {
EntrySize = 16;
+ } else {
+ assert(Kind.isMergeableConst32() && "unknown data width");
+ EntrySize = 32;
}
}
@@ -375,6 +377,8 @@ MCSection *TargetLoweringObjectFileELF::
return MergeableConst8Section;
if (Kind.isMergeableConst16() && MergeableConst16Section)
return MergeableConst16Section;
+ if (Kind.isMergeableConst32() && MergeableConst32Section)
+ return MergeableConst32Section;
if (Kind.isReadOnly())
return ReadOnlySection;
Modified: llvm/trunk/lib/MC/MCObjectFileInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=261584&r1=261583&r2=261584&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectFileInfo.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectFileInfo.cpp Mon Feb 22 16:23:11 2016
@@ -469,6 +469,10 @@ void MCObjectFileInfo::initELFMCObjectFi
Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS,
ELF::SHF_ALLOC | ELF::SHF_MERGE, 16, "");
+ MergeableConst32Section =
+ Ctx->getELFSection(".rodata.cst32", ELF::SHT_PROGBITS,
+ ELF::SHF_ALLOC | ELF::SHF_MERGE, 32, "");
+
StaticCtorSection = Ctx->getELFSection(".ctors", ELF::SHT_PROGBITS,
ELF::SHF_ALLOC | ELF::SHF_WRITE);
Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=261584&r1=261583&r2=261584&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Mon Feb 22 16:23:11 2016
@@ -202,6 +202,7 @@ SectionKind TargetLoweringObjectFile::ge
case 4: return SectionKind::getMergeableConst4();
case 8: return SectionKind::getMergeableConst8();
case 16: return SectionKind::getMergeableConst16();
+ case 32: return SectionKind::getMergeableConst32();
default:
return SectionKind::getReadOnly();
}
Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp?rev=261584&r1=261583&r2=261584&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Mon Feb 22 16:23:11 2016
@@ -176,6 +176,11 @@ MCSection *X86WindowsTargetObjectFile::g
COMDATSymName = "__xmm@" + scalarConstantToHexString(C);
Align = 16;
}
+ } else if (Kind.isMergeableConst32()) {
+ if (Align <= 32) {
+ COMDATSymName = "__ymm@" + scalarConstantToHexString(C);
+ Align = 32;
+ }
}
if (!COMDATSymName.empty())
Modified: llvm/trunk/test/CodeGen/X86/global-sections.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/global-sections.ll?rev=261584&r1=261583&r2=261584&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/global-sections.ll (original)
+++ llvm/trunk/test/CodeGen/X86/global-sections.ll Mon Feb 22 16:23:11 2016
@@ -298,3 +298,14 @@ bb7:
; WIN32-SECTIONS: .section .rdata,"dr",one_only,_G15
; WIN32-SECTIONS: _G15:
+
+ at G16 = unnamed_addr constant i256 0
+
+; LINUX: .section .rodata.cst32,"aM", at progbits,32
+; LINUX: G16:
+
+; LINUX-SECTIONS: .section .rodata.cst32,"aM", at progbits,32
+; LINUX-SECTIONS: G16:
+
+; WIN32-SECTIONS: .section .rdata,"dr",one_only,_G16
+; WIN32-SECTIONS: _G16:
Modified: llvm/trunk/test/CodeGen/X86/win_cst_pool.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/win_cst_pool.ll?rev=261584&r1=261583&r2=261584&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/win_cst_pool.ll (original)
+++ llvm/trunk/test/CodeGen/X86/win_cst_pool.ll Mon Feb 22 16:23:11 2016
@@ -1,4 +1,4 @@
-; RUN: llc < %s -mtriple=x86_64-win32 -mattr=sse2 | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-win32 -mattr=sse2 -mattr=avx | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"
@@ -77,3 +77,17 @@ define float @pr23966(i32 %a) {
; CHECK-NEXT: __real at bf8000003f800000:
; CHECK-NEXT: .long 1065353216
; CHECK-NEXT: .long 3212836864
+
+define <4 x i64> @ymm() {
+entry:
+ ret <4 x i64> <i64 8589934593, i64 17179869187, i64 8589934593, i64 17179869187>
+}
+
+; CHECK: .globl __ymm at 0000000400000003000000020000000100000004000000030000000200000001
+; CHECK: .section .rdata,"dr",discard,__ymm at 0000000400000003000000020000000100000004000000030000000200000001
+; CHECK: .p2align 5
+; CHECK: __ymm at 0000000400000003000000020000000100000004000000030000000200000001:
+; CHECK: .quad 8589934593 # 0x200000001
+; CHECK: .quad 17179869187 # 0x400000003
+; CHECK: .quad 8589934593 # 0x200000001
+; CHECK: .quad 17179869187
More information about the llvm-commits
mailing list