[PATCH] D66639: AArch64: avoid cycle when forming post-increment NEON loads

Tim Northover via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 23 04:07:54 PDT 2019


t.p.northover created this revision.
Herald added subscribers: arphaman, hiraditya, kristof.beyls, javed.absar, mcrosier.
Herald added a project: LLVM.

Inserting a value into Visited has the effect of terminating a search for predecessors if that node is seen. This is legitimate for the base address (as used in DAGCombiner.cpp), and acts as a slight performance optimization. But the vector-building node here can be part of a legitimate cycle so we shouldn't stop searching there.

Should fix https://bugs.llvm.org/show_bug.cgi?id=43056.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66639

Files:
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/test/CodeGen/AArch64/arm64-indexed-vector-ldst.ll


Index: llvm/test/CodeGen/AArch64/arm64-indexed-vector-ldst.ll
===================================================================
--- llvm/test/CodeGen/AArch64/arm64-indexed-vector-ldst.ll
+++ llvm/test/CodeGen/AArch64/arm64-indexed-vector-ldst.ll
@@ -6319,3 +6319,22 @@
   store <8 x i8> %sub, <8 x i8>* %p
   ret void
 }
+
+define <4 x i32> @test_inc_cycle(<4 x i32> %vec, i32* %in) {
+; CHECK-LABEL: test_inc_cycle:
+; CHECK: ld1.s { v0 }[0], [x0]{{$}}
+
+  %elt = load i32, i32* %in
+  %newvec = insertelement <4 x i32> %vec, i32 %elt, i32 0
+
+  ; %inc cannot be %elt directly because we check that the load is only
+  ; used by the insert before trying to form post-inc.
+  %inc.vec = bitcast <4 x i32> %newvec to <2 x i64>
+  %inc = extractelement <2 x i64> %inc.vec, i32 0
+  %newaddr = getelementptr i32, i32* %in, i64 %inc
+  store i32* %newaddr, i32** @var
+
+  ret <4 x i32> %newvec
+}
+
+ at var = global i32* null
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -10692,7 +10692,7 @@
     // are predecessors to each other or the Vector.
     SmallPtrSet<const SDNode *, 32> Visited;
     SmallVector<const SDNode *, 16> Worklist;
-    Visited.insert(N);
+    Visited.insert(Addr.getNode());
     Worklist.push_back(User);
     Worklist.push_back(LD);
     Worklist.push_back(Vector.getNode());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66639.216799.patch
Type: text/x-patch
Size: 1487 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190823/b83386fe/attachment.bin>


More information about the llvm-commits mailing list