[llvm] dc8d16c - [AArch64][GlobalISel] Add MMOs to constant pool loads to allow LICM hoisting.
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Wed May 12 09:47:14 PDT 2021
Author: Amara Emerson
Date: 2021-05-12T09:47:09-07:00
New Revision: dc8d16c03f4fcdc0dbfc2925621f6d0064bca31c
URL: https://github.com/llvm/llvm-project/commit/dc8d16c03f4fcdc0dbfc2925621f6d0064bca31c
DIFF: https://github.com/llvm/llvm-project/commit/dc8d16c03f4fcdc0dbfc2925621f6d0064bca31c.diff
LOG: [AArch64][GlobalISel] Add MMOs to constant pool loads to allow LICM hoisting.
This caused performance regressions vs SDAG on SingleSource/Benchmarks/Adobe-C++
Added:
llvm/test/CodeGen/AArch64/GlobalISel/select-const-pool.mir
Modified:
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index 0829f77151110..c763b7b3fae2a 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -31,6 +31,7 @@
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
+#include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/TargetOpcodes.h"
@@ -3991,14 +3992,17 @@ AArch64InstructionSelector::emitConstantPoolEntry(const Constant *CPVal,
MachineInstr *AArch64InstructionSelector::emitLoadFromConstantPool(
const Constant *CPVal, MachineIRBuilder &MIRBuilder) const {
- unsigned CPIdx = emitConstantPoolEntry(CPVal, MIRBuilder.getMF());
+ auto &MF = MIRBuilder.getMF();
+ unsigned CPIdx = emitConstantPoolEntry(CPVal, MF);
auto Adrp =
MIRBuilder.buildInstr(AArch64::ADRP, {&AArch64::GPR64RegClass}, {})
.addConstantPoolIndex(CPIdx, 0, AArch64II::MO_PAGE);
MachineInstr *LoadMI = nullptr;
- switch (MIRBuilder.getDataLayout().getTypeStoreSize(CPVal->getType())) {
+ MachinePointerInfo PtrInfo = MachinePointerInfo::getConstantPool(MF);
+ unsigned Size = MIRBuilder.getDataLayout().getTypeStoreSize(CPVal->getType());
+ switch (Size) {
case 16:
LoadMI =
&*MIRBuilder
@@ -4025,6 +4029,9 @@ MachineInstr *AArch64InstructionSelector::emitLoadFromConstantPool(
<< *CPVal->getType());
return nullptr;
}
+ LoadMI->addMemOperand(MF, MF.getMachineMemOperand(PtrInfo,
+ MachineMemOperand::MOLoad,
+ Size, Align(Size)));
constrainSelectedInstRegOperands(*Adrp, TII, TRI, RBI);
constrainSelectedInstRegOperands(*LoadMI, TII, TRI, RBI);
return LoadMI;
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/select-const-pool.mir b/llvm/test/CodeGen/AArch64/GlobalISel/select-const-pool.mir
new file mode 100644
index 0000000000000..0e4e364e55714
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/select-const-pool.mir
@@ -0,0 +1,31 @@
+# RUN: llc -mtriple=aarch64-- -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s
+---
+name: test_constant_vec_pool_v2f64
+alignment: 4
+legalized: true
+regBankSelected: true
+tracksRegLiveness: true
+liveins:
+ - { reg: '$x0' }
+frameInfo:
+ maxAlignment: 1
+machineFunctionInfo: {}
+body: |
+ bb.1:
+ liveins: $x0
+ ; Check that we have an MMO on the load, which is needed for MachineLICM to hoist it.
+ ; CHECK-LABEL: name: test_constant_vec_pool_v2f64
+ ; CHECK: liveins: $x0
+ ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY $x0
+ ; CHECK: [[ADRP:%[0-9]+]]:gpr64common = ADRP target-flags(aarch64-page) %const.0
+ ; CHECK: [[LDRQui:%[0-9]+]]:fpr128 = LDRQui [[ADRP]], target-flags(aarch64-pageoff, aarch64-nc) %const.0 :: (load 16 from constant-pool)
+ ; CHECK: STRQui [[LDRQui]], [[COPY]], 0 :: (store 16)
+ ; CHECK: RET_ReallyLR
+ %0:gpr(p0) = COPY $x0
+ %3:fpr(s64) = G_FCONSTANT double 5.000000e-01
+ %2:fpr(s64) = G_FCONSTANT double 1.600000e+01
+ %1:fpr(<2 x s64>) = G_BUILD_VECTOR %2(s64), %3(s64)
+ G_STORE %1(<2 x s64>), %0(p0) :: (store 16)
+ RET_ReallyLR
+
+...
More information about the llvm-commits
mailing list