[llvm] r368197 - [LoopVectorize][X86] Add test case for missed vectorization from PR42674.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 7 12:07:10 PDT 2019


Author: ctopper
Date: Wed Aug  7 12:07:10 2019
New Revision: 368197

URL: http://llvm.org/viewvc/llvm-project?rev=368197&view=rev
Log:
[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.

Added:
    llvm/trunk/test/Transforms/LoopVectorize/X86/pr42674.ll

Added: llvm/trunk/test/Transforms/LoopVectorize/X86/pr42674.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopVectorize/X86/pr42674.ll?rev=368197&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/LoopVectorize/X86/pr42674.ll (added)
+++ llvm/trunk/test/Transforms/LoopVectorize/X86/pr42674.ll Wed Aug  7 12:07:10 2019
@@ -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
+
+ at 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
+}




More information about the llvm-commits mailing list