[PATCH] D84884: [SelectionDAG] Fix lowering of vector geps

Jon Roelofs via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 30 13:57:36 PDT 2020


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGafae6d97fa55: [SelectionDAG] Fix lowering of vector geps (authored by jroelofs).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84884/new/

https://reviews.llvm.org/D84884

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/test/CodeGen/AArch64/vector-gep.ll


Index: llvm/test/CodeGen/AArch64/vector-gep.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AArch64/vector-gep.ll
@@ -0,0 +1,21 @@
+; RUN: llc < %s -mtriple=arm64_32-apple-watchos2.0.0 --aarch64-neon-syntax=generic | FileCheck %s
+
+target datalayout = "e-m:o-p:32:32-i64:64-i128:128-n32:64-S128"
+target triple = "arm64_32-apple-watchos2.0.0"
+
+; CHECK-LABEL: lCPI0_0:
+; CHECK-NEXT:    .quad 36
+; CHECK-NEXT:    .quad 4804
+
+define <2 x i8*> @vector_gep(<2 x i8*> %0) {
+; CHECK-LABEL: vector_gep:
+; CHECK:         adrp x[[REG8:[123]?[0-9]]], lCPI0_0 at PAGE
+; CHECK:         ldr q[[REG1:[0-9]+]], [x[[REG8]], lCPI0_0 at PAGEOFF]
+; CHECK:         add v[[REG0:[0-9]+]].2d, v[[REG0]].2d, v[[REG1]].2d
+; CHECK:         movi v[[REG1]].2d, #0x000000ffffffff
+; CHECK:         and v[[REG0]].16b, v[[REG0]].16b, v[[REG1]].16b
+; CHECK:         ret
+entry:
+  %1 = getelementptr i8, <2 x i8*> %0, <2 x i32> <i32 36, i32 4804>
+  ret <2 x i8*> %1
+}
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3753,8 +3753,6 @@
   SDValue N = getValue(Op0);
   SDLoc dl = getCurSDLoc();
   auto &TLI = DAG.getTargetLoweringInfo();
-  MVT PtrTy = TLI.getPointerTy(DAG.getDataLayout(), AS);
-  MVT PtrMemTy = TLI.getPointerMemTy(DAG.getDataLayout(), AS);
 
   // Normalize Vector GEP - all scalar operands should be converted to the
   // splat vector.
@@ -3880,6 +3878,13 @@
     }
   }
 
+  MVT PtrTy = TLI.getPointerTy(DAG.getDataLayout(), AS);
+  MVT PtrMemTy = TLI.getPointerMemTy(DAG.getDataLayout(), AS);
+  if (IsVectorGEP) {
+    PtrTy = MVT::getVectorVT(PtrTy, VectorElementCount);
+    PtrMemTy = MVT::getVectorVT(PtrMemTy, VectorElementCount);
+  }
+
   if (PtrMemTy != PtrTy && !cast<GEPOperator>(I).isInBounds())
     N = DAG.getPtrExtendInReg(N, dl, PtrMemTy);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84884.282041.patch
Type: text/x-patch
Size: 2018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200730/40a4ca70/attachment.bin>


More information about the llvm-commits mailing list