summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2019-08-07 19:07:10 +0000
committerCraig Topper <craig.topper@intel.com>2019-08-07 19:07:10 +0000
commit0a05a04e5bdd2e93a88c9dbc8ff59dcee0de399c (patch)
tree5561fcc6fe58ec647bce57861e6260c08027ddc0
parentba55970c150b781adcd401e6ea77a061e9aed14b (diff)
downloadbcm5719-llvm-0a05a04e5bdd2e93a88c9dbc8ff59dcee0de399c.tar.gz
bcm5719-llvm-0a05a04e5bdd2e93a88c9dbc8ff59dcee0de399c.zip
[LoopVectorize][X86] Add test case for missed vectorization from PR42674.
We do end vectorizing the code, but use an interleave factor that is too high and causes the vector code to be dead. llvm-svn: 368197
-rw-r--r--llvm/test/Transforms/LoopVectorize/X86/pr42674.ll41
1 files changed, 41 insertions, 0 deletions
diff --git a/llvm/test/Transforms/LoopVectorize/X86/pr42674.ll b/llvm/test/Transforms/LoopVectorize/X86/pr42674.ll
new file mode 100644
index 00000000000..571ae2d5b18
--- /dev/null
+++ b/llvm/test/Transforms/LoopVectorize/X86/pr42674.ll
@@ -0,0 +1,41 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt %s -loop-vectorize -instcombine -simplifycfg -mtriple=x86_64-unknown-linux-gnu -mcpu=skylake-avx512 -S | FileCheck %s
+
+@bytes = global [128 x i8] zeroinitializer, align 16
+
+; FIXME: We should end up with vector code for this loop, but don't because
+; we try to create VF=64,UF=4 loop, but the scalar trip count is only 128 so
+; the vector loop becomes dead code leaving only a scalar remainder.
+define zeroext i8 @sum() {
+; CHECK-LABEL: @sum(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_BODY:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
+; CHECK-NEXT: [[R_010:%.*]] = phi i8 [ 0, [[ENTRY]] ], [ [[ADD:%.*]], [[FOR_BODY]] ]
+; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [128 x i8], [128 x i8]* @bytes, i64 0, i64 [[INDVARS_IV]]
+; CHECK-NEXT: [[TMP0:%.*]] = load i8, i8* [[ARRAYIDX]], align 1
+; CHECK-NEXT: [[ADD]] = add i8 [[TMP0]], [[R_010]]
+; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
+; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 128
+; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]], !llvm.loop !0
+; CHECK: for.end:
+; CHECK-NEXT: ret i8 [[ADD]]
+;
+entry:
+ br label %for.body
+
+for.body: ; preds = %for.body, %entry
+ %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
+ %r.010 = phi i8 [ 0, %entry ], [ %add, %for.body ]
+ %arrayidx = getelementptr inbounds [128 x i8], [128 x i8]* @bytes, i64 0, i64 %indvars.iv
+ %0 = load i8, i8* %arrayidx, align 1
+ %add = add i8 %0, %r.010
+ %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
+ %exitcond = icmp eq i64 %indvars.iv.next, 128
+ br i1 %exitcond, label %for.end, label %for.body
+
+for.end: ; preds = %for.body
+ %add.lcssa = phi i8 [ %add, %for.body ]
+ ret i8 %add.lcssa
+}
OpenPOWER on IntegriCloud