[llvm] c6b9e8e - [SLP][NFC]Add a test with non-profitable vectorization, NFC

via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 3 04:17:19 PDT 2026


Author: Alexey Bataev
Date: 2026-10-03T07:17:12-04:00
New Revision: c6b9e8e8600724204d85654070e6e5dc4b34643a

URL: https://github.com/llvm/llvm-project/commit/c6b9e8e8600724204d85654070e6e5dc4b34643a
DIFF: https://github.com/llvm/llvm-project/commit/c6b9e8e8600724204d85654070e6e5dc4b34643a.diff

LOG: [SLP][NFC]Add a test with non-profitable vectorization, NFC



Reviewers: 

Pull Request: https://github.com/llvm/llvm-project/pull/228695

Added: 
    llvm/test/Transforms/SLPVectorizer/X86/duplicated-lane-consecutive-loads.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/SLPVectorizer/X86/duplicated-lane-consecutive-loads.ll b/llvm/test/Transforms/SLPVectorizer/X86/duplicated-lane-consecutive-loads.ll
new file mode 100644
index 0000000000000..8a3836a722d32
--- /dev/null
+++ b/llvm/test/Transforms/SLPVectorizer/X86/duplicated-lane-consecutive-loads.ll
@@ -0,0 +1,70 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; RUN: opt -passes=slp-vectorizer -S -mtriple=x86_64-unknown-linux-gnu -mcpu=skylake-avx512 < %s | FileCheck %s
+
+; The last store repeats the value of the third one, so the 4-lane bundle has 3
+; unique values loaded from consecutive addresses. A single <3 x double> load
+; plus a shuffle is cheaper than the masked gather of the duplicated lanes.
+
+ at src = external global [4096 x double]
+ at dst = external global [8 x double]
+
+define void @test(i64 %i) {
+; CHECK-LABEL: define void @test(
+; CHECK-SAME: i64 [[I:%.*]]) #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT:  [[ENTRY:.*]]:
+; CHECK-NEXT:    [[TMP0:%.*]] = insertelement <4 x i64> poison, i64 [[I]], i64 0
+; CHECK-NEXT:    [[TMP6:%.*]] = shufflevector <4 x i64> [[TMP0]], <4 x i64> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    br label %[[LOOP:.*]]
+; CHECK:       [[LOOP]]:
+; CHECK-NEXT:    [[IV:%.*]] = phi i64 [ 0, %[[ENTRY]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]
+; CHECK-NEXT:    [[TMP7:%.*]] = add <4 x i64> [[TMP6]], <i64 6, i64 8, i64 7, i64 7>
+; CHECK-NEXT:    [[TMP8:%.*]] = getelementptr double, <4 x ptr> <ptr @src, ptr @src, ptr @src, ptr @src>, <4 x i64> [[TMP7]]
+; CHECK-NEXT:    [[TMP1:%.*]] = call <4 x double> @llvm.masked.gather.v4f64.v4p0(<4 x ptr> align 8 [[TMP8]], <4 x i1> splat (i1 true), <4 x double> poison)
+; CHECK-NEXT:    [[TMP2:%.*]] = fsub <4 x double> zeroinitializer, [[TMP1]]
+; CHECK-NEXT:    [[TMP3:%.*]] = fadd <4 x double> [[TMP2]], splat (double 1.000000e+00)
+; CHECK-NEXT:    [[TMP4:%.*]] = fcmp olt <4 x double> [[TMP3]], zeroinitializer
+; CHECK-NEXT:    [[TMP5:%.*]] = select <4 x i1> [[TMP4]], <4 x double> splat (double 1.000000e+00), <4 x double> zeroinitializer
+; CHECK-NEXT:    store <4 x double> [[TMP5]], ptr getelementptr inbounds nuw (i8, ptr @dst, i64 8), align 8
+; CHECK-NEXT:    [[IV_NEXT]] = add nuw i64 [[IV]], 1
+; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp eq i64 [[IV_NEXT]], 100
+; CHECK-NEXT:    br i1 [[EXITCOND]], label %[[EXIT:.*]], label %[[LOOP]]
+; CHECK:       [[EXIT]]:
+; CHECK-NEXT:    ret void
+;
+entry:
+  br label %loop
+
+loop:
+  %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
+  %idx.0 = add i64 %i, 6
+  %gep.0 = getelementptr double, ptr @src, i64 %idx.0
+  %ld.0 = load double, ptr %gep.0, align 8
+  %neg.0 = fsub double 0.000000e+00, %ld.0
+  %idx.1 = add i64 %i, 7
+  %gep.1 = getelementptr double, ptr @src, i64 %idx.1
+  %ld.1 = load double, ptr %gep.1, align 8
+  %neg.1 = fsub double 0.000000e+00, %ld.1
+  %idx.2 = add i64 %i, 8
+  %gep.2 = getelementptr double, ptr @src, i64 %idx.2
+  %ld.2 = load double, ptr %gep.2, align 8
+  %neg.2 = fsub double 0.000000e+00, %ld.2
+  %add.0 = fadd double %neg.0, 1.000000e+00
+  %cmp.0 = fcmp olt double %add.0, 0.000000e+00
+  %sel.0 = select i1 %cmp.0, double 1.000000e+00, double 0.000000e+00
+  store double %sel.0, ptr getelementptr inbounds nuw (i8, ptr @dst, i64 8), align 8
+  %add.2 = fadd double %neg.2, 1.000000e+00
+  %cmp.2 = fcmp olt double %add.2, 0.000000e+00
+  %sel.2 = select i1 %cmp.2, double 1.000000e+00, double 0.000000e+00
+  store double %sel.2, ptr getelementptr inbounds nuw (i8, ptr @dst, i64 16), align 8
+  %add.1 = fadd double %neg.1, 1.000000e+00
+  %cmp.1 = fcmp olt double %add.1, 0.000000e+00
+  %sel.1 = select i1 %cmp.1, double 1.000000e+00, double 0.000000e+00
+  store double %sel.1, ptr getelementptr inbounds nuw (i8, ptr @dst, i64 24), align 8
+  store double %sel.1, ptr getelementptr inbounds nuw (i8, ptr @dst, i64 32), align 8
+  %iv.next = add nuw i64 %iv, 1
+  %exitcond = icmp eq i64 %iv.next, 100
+  br i1 %exitcond, label %exit, label %loop
+
+exit:
+  ret void
+}


        


More information about the llvm-commits mailing list