]> granicus.if.org Git - llvm/commitdiff
[LoopVectorize][X86] Add test case for missed vectorization from PR42674.
authorCraig Topper <craig.topper@intel.com>
Wed, 7 Aug 2019 19:07:10 +0000 (19:07 +0000)
committerCraig Topper <craig.topper@intel.com>
Wed, 7 Aug 2019 19:07:10 +0000 (19:07 +0000)
We do end vectorizing the code, but use an interleave factor that
is too high and causes the vector code to be dead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368197 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/LoopVectorize/X86/pr42674.ll [new file with mode: 0644]

diff --git a/test/Transforms/LoopVectorize/X86/pr42674.ll b/test/Transforms/LoopVectorize/X86/pr42674.ll
new file mode 100644 (file)
index 0000000..571ae2d
--- /dev/null
@@ -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
+}