diff options
author | Stefan Pintilie <stefanp@ca.ibm.com> | 2018-10-01 20:16:27 +0000 |
---|---|---|
committer | Stefan Pintilie <stefanp@ca.ibm.com> | 2018-10-01 20:16:27 +0000 |
commit | 6e91f2afe82e2d75001a4c92266135a838c7e4f4 (patch) | |
tree | 81a0dc64ee317759b9fe8c0116f948d471d1e7d9 | |
parent | 206d8bab74c8210e0d188645a33fb0f17c973ac6 (diff) |
[PowerPC] Folding XForm to DForm loads requires alignment for some DForm loads.
Going from XForm Load to DSForm Load requires that the immediate be 4 byte
aligned.
If we are not aligned we must leave the load as LDX (XForm).
This bug is causing a compile-time failure in the benchmark h264ref.
Differential Revision: https://reviews.llvm.org/D51988
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCInstrInfo.cpp | 8 | ||||
-rw-r--r-- | llvm/test/CodeGen/PowerPC/p9-dform-load-alignment.ll | 16 |
2 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp index f9d173699ec..883f8390b7d 100644 --- a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp +++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp @@ -3150,6 +3150,14 @@ bool PPCInstrInfo::isImmElgibleForForwarding(const MachineOperand &ImmMO, III.TruncateImmTo || III.ImmWidth != 16) return false; + // Going from XForm to DForm loads means that the displacement needs to be + // not just an immediate but also a multiple of 4, or 16 depending on the + // load. A DForm load cannot be represented if it is a multiple of say 2. + // XForm loads do not have this restriction. + if (ImmMO.isGlobal() && + ImmMO.getGlobal()->getAlignment() < III.ImmMustBeMultipleOf) + return false; + return true; } diff --git a/llvm/test/CodeGen/PowerPC/p9-dform-load-alignment.ll b/llvm/test/CodeGen/PowerPC/p9-dform-load-alignment.ll new file mode 100644 index 00000000000..b672eef8740 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/p9-dform-load-alignment.ll @@ -0,0 +1,16 @@ +; RUN: llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-unknown \ +; RUN: -verify-machineinstrs -ppc-asm-full-reg-names \ +; RUN: -ppc-vsr-nums-as-vr < %s | FileCheck %s + +@best8x8mode = external dso_local local_unnamed_addr global [4 x i16], align 2 +define dso_local void @AlignDSForm() local_unnamed_addr { +entry: + %0 = load <4 x i16>, <4 x i16>* bitcast ([4 x i16]* @best8x8mode to <4 x i16>*), align 2 + store <4 x i16> %0, <4 x i16>* undef, align 4 + unreachable +; CHECK-LABEL: AlignDSForm +; CHECK: addis r{{[0-9]+}}, r{{[0-9]+}}, best8x8mode@toc@ha +; CHECK: addi r[[REG:[0-9]+]], r{{[0-9]+}}, best8x8mode@toc@l +; CHECK: ldx r{{[0-9]+}}, 0, r[[REG]] +} + |