[PATCH] D146540: [SLP] Add test to check for GEP vectorization
Zain Jaffal via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 22 09:21:40 PDT 2023
zjaffal updated this revision to Diff 507392.
zjaffal added a comment.
Move function from AArch64 to be a generic test.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D146540/new/
https://reviews.llvm.org/D146540
Files:
llvm/test/Transforms/SLPVectorizer/slp-getelementptr.ll
Index: llvm/test/Transforms/SLPVectorizer/slp-getelementptr.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/SLPVectorizer/slp-getelementptr.ll
@@ -0,0 +1,79 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
+; RUN: opt -S -passes=slp-vectorizer < %s | FileCheck %s
+
+define void @should_vectorize_gep() {
+; CHECK-LABEL: define void @should_vectorize_gep() {
+; CHECK-NEXT: bb:
+; CHECK-NEXT: [[GETELEMENTPTR:%.*]] = getelementptr i32, ptr null, i64 1
+; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr null, align 2
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 [[LOAD]] to i64
+; CHECK-NEXT: [[GETELEMENTPTR1:%.*]] = getelementptr i32, ptr null, i64 1
+; CHECK-NEXT: [[LOAD2:%.*]] = load i32, ptr null, align 2
+; CHECK-NEXT: [[ZEXT3:%.*]] = zext i32 [[LOAD2]] to i64
+; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[ZEXT]], [[ZEXT3]]
+; CHECK-NEXT: [[GETELEMENTPTR4:%.*]] = getelementptr i32, ptr null, i64 [[SUB]]
+; CHECK-NEXT: [[GETELEMENTPTR5:%.*]] = getelementptr i32, ptr null, i64 2
+; CHECK-NEXT: [[LOAD6:%.*]] = load i32, ptr [[GETELEMENTPTR]], align 2
+; CHECK-NEXT: [[ZEXT7:%.*]] = zext i32 [[LOAD6]] to i64
+; CHECK-NEXT: [[GETELEMENTPTR8:%.*]] = getelementptr i32, ptr null, i64 2
+; CHECK-NEXT: [[LOAD9:%.*]] = load i32, ptr [[GETELEMENTPTR1]], align 2
+; CHECK-NEXT: [[ZEXT10:%.*]] = zext i32 [[LOAD9]] to i64
+; CHECK-NEXT: [[SUB11:%.*]] = sub i64 [[ZEXT7]], [[ZEXT10]]
+; CHECK-NEXT: [[GETELEMENTPTR12:%.*]] = getelementptr i32, ptr null, i64 [[SUB11]]
+; CHECK-NEXT: [[GETELEMENTPTR13:%.*]] = getelementptr i32, ptr null, i64 3
+; CHECK-NEXT: [[LOAD14:%.*]] = load i32, ptr [[GETELEMENTPTR5]], align 2
+; CHECK-NEXT: [[ZEXT15:%.*]] = zext i32 [[LOAD14]] to i64
+; CHECK-NEXT: [[GETELEMENTPTR16:%.*]] = getelementptr i32, ptr null, i64 3
+; CHECK-NEXT: [[LOAD17:%.*]] = load i32, ptr [[GETELEMENTPTR8]], align 2
+; CHECK-NEXT: [[ZEXT18:%.*]] = zext i32 [[LOAD17]] to i64
+; CHECK-NEXT: [[SUB19:%.*]] = sub i64 [[ZEXT15]], [[ZEXT18]]
+; CHECK-NEXT: [[GETELEMENTPTR20:%.*]] = getelementptr i32, ptr null, i64 [[SUB19]]
+; CHECK-NEXT: [[GETELEMENTPTR21:%.*]] = getelementptr i32, ptr null, i64 4
+; CHECK-NEXT: [[LOAD22:%.*]] = load i32, ptr [[GETELEMENTPTR13]], align 2
+; CHECK-NEXT: [[ZEXT23:%.*]] = zext i32 [[LOAD22]] to i64
+; CHECK-NEXT: [[GETELEMENTPTR24:%.*]] = getelementptr i32, ptr null, i64 4
+; CHECK-NEXT: [[LOAD25:%.*]] = load i32, ptr [[GETELEMENTPTR16]], align 2
+; CHECK-NEXT: [[ZEXT26:%.*]] = zext i32 [[LOAD25]] to i64
+; CHECK-NEXT: [[SUB27:%.*]] = sub i64 [[ZEXT23]], [[ZEXT26]]
+; CHECK-NEXT: [[GETELEMENTPTR28:%.*]] = getelementptr i32, ptr null, i64 [[SUB27]]
+; CHECK-NEXT: call void @use_4(ptr [[GETELEMENTPTR28]], ptr [[GETELEMENTPTR20]], ptr [[GETELEMENTPTR12]], ptr [[GETELEMENTPTR4]])
+; CHECK-NEXT: ret void
+;
+bb:
+ %getelementptr = getelementptr i32, ptr null, i64 1
+ %load = load i32, ptr null, align 2
+ %zext = zext i32 %load to i64
+ %getelementptr1 = getelementptr i32, ptr null, i64 1
+ %load2 = load i32, ptr null, align 2
+ %zext3 = zext i32 %load2 to i64
+ %sub = sub i64 %zext, %zext3
+ %getelementptr4 = getelementptr i32, ptr null, i64 %sub
+ %getelementptr5 = getelementptr i32, ptr null, i64 2
+ %load6 = load i32, ptr %getelementptr, align 2
+ %zext7 = zext i32 %load6 to i64
+ %getelementptr8 = getelementptr i32, ptr null, i64 2
+ %load9 = load i32, ptr %getelementptr1, align 2
+ %zext10 = zext i32 %load9 to i64
+ %sub11 = sub i64 %zext7, %zext10
+ %getelementptr12 = getelementptr i32, ptr null, i64 %sub11
+ %getelementptr13 = getelementptr i32, ptr null, i64 3
+ %load14 = load i32, ptr %getelementptr5, align 2
+ %zext15 = zext i32 %load14 to i64
+ %getelementptr16 = getelementptr i32, ptr null, i64 3
+ %load17 = load i32, ptr %getelementptr8, align 2
+ %zext18 = zext i32 %load17 to i64
+ %sub19 = sub i64 %zext15, %zext18
+ %getelementptr20 = getelementptr i32, ptr null, i64 %sub19
+ %getelementptr21 = getelementptr i32, ptr null, i64 4
+ %load22 = load i32, ptr %getelementptr13, align 2
+ %zext23 = zext i32 %load22 to i64
+ %getelementptr24 = getelementptr i32, ptr null, i64 4
+ %load25 = load i32, ptr %getelementptr16, align 2
+ %zext26 = zext i32 %load25 to i64
+ %sub27 = sub i64 %zext23, %zext26
+ %getelementptr28 = getelementptr i32, ptr null, i64 %sub27
+ call void @use_4(ptr %getelementptr28, ptr %getelementptr20, ptr %getelementptr12, ptr %getelementptr4)
+ ret void
+}
+
+declare void @use_4(ptr, ptr, ptr, ptr)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146540.507392.patch
Type: text/x-patch
Size: 4638 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230322/9c60ba7e/attachment.bin>
More information about the llvm-commits
mailing list