[PATCH] D51988: [PowerPC] Folding XForm to DForm loads requires alignment for some DForm loads.

Stefan Pintilie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 1 13:18:19 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL343525: [PowerPC] Folding XForm to DForm loads requires alignment for some DForm loads. (authored by stefanp, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D51988?vs=167549&id=167807#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51988

Files:
  llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp
  llvm/trunk/test/CodeGen/PowerPC/p9-dform-load-alignment.ll


Index: llvm/trunk/test/CodeGen/PowerPC/p9-dform-load-alignment.ll
===================================================================
--- llvm/trunk/test/CodeGen/PowerPC/p9-dform-load-alignment.ll
+++ llvm/trunk/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
+
+ at 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 at toc@ha
+; CHECK: addi r[[REG:[0-9]+]], r{{[0-9]+}}, best8x8mode at toc@l
+; CHECK: ldx r{{[0-9]+}}, 0, r[[REG]]
+}
+
Index: llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp
===================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -3150,6 +3150,14 @@
        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;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51988.167807.patch
Type: text/x-patch
Size: 1702 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181001/729bbaca/attachment.bin>


More information about the llvm-commits mailing list