From b7ed29df5dd53b96fbef359fdfdba5ba75867516 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Thu, 5 Mar 2026 10:54:18 -0800 Subject: [PATCH] [SLP][NFC]Add a test with a loop with profiling info, NFC --- .../X86/expected-prof-consecutive-access.ll | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 llvm/test/Transforms/SLPVectorizer/X86/expected-prof-consecutive-access.ll diff --git a/llvm/test/Transforms/SLPVectorizer/X86/expected-prof-consecutive-access.ll b/llvm/test/Transforms/SLPVectorizer/X86/expected-prof-consecutive-access.ll new file mode 100644 index 000000000000..db356f618f44 --- /dev/null +++ b/llvm/test/Transforms/SLPVectorizer/X86/expected-prof-consecutive-access.ll @@ -0,0 +1,66 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -passes=slp-vectorizer -S -mtriple=x86_64-unknown-linux -pass-remarks-output=%t | FileCheck %s +; RUN: FileCheck --input-file=%t --check-prefix=YAML %s + +; YAML: --- !Passed +; YAML-NEXT: Pass: slp-vectorizer +; YAML-NEXT: Name: VectorizedList +; YAML-NEXT: Function: test +; YAML-NEXT: Args: +; YAML-NEXT: - String: 'SLP vectorized with cost ' +; YAML-NEXT: - Cost: '-2' +; YAML-NEXT: - String: ' and with tree size ' +; YAML-NEXT: - TreeSize: '7' +; YAML-NEXT: ... +; +define double @test(ptr %a, i32 %n) { +; CHECK-LABEL: @test( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CMP15:%.*]] = icmp eq i32 [[N:%.*]], 0 +; CHECK-NEXT: br i1 [[CMP15]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY:%.*]] +; CHECK: for.cond.cleanup: +; CHECK-NEXT: [[TMP0:%.*]] = phi <2 x double> [ zeroinitializer, [[ENTRY:%.*]] ], [ [[TMP5:%.*]], [[FOR_BODY]] ] +; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x double> [[TMP0]], i32 0 +; CHECK-NEXT: [[TMP2:%.*]] = extractelement <2 x double> [[TMP0]], i32 1 +; CHECK-NEXT: [[MUL:%.*]] = fmul double [[TMP1]], [[TMP2]] +; CHECK-NEXT: ret double [[MUL]] +; CHECK: for.body: +; CHECK-NEXT: [[I_018:%.*]] = phi i32 [ [[ADD5:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY]] ] +; CHECK-NEXT: [[TMP3:%.*]] = phi <2 x double> [ [[TMP5]], [[FOR_BODY]] ], [ zeroinitializer, [[ENTRY]] ] +; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[I_018]] to i64 +; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds double, ptr [[A:%.*]], i64 [[IDXPROM]] +; CHECK-NEXT: [[TMP4:%.*]] = load <2 x double>, ptr [[ARRAYIDX]], align 8 +; CHECK-NEXT: [[TMP5]] = fadd <2 x double> [[TMP3]], [[TMP4]] +; CHECK-NEXT: [[ADD5]] = add i32 [[I_018]], 2 +; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[ADD5]], [[N]] +; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP]], !prof [[PROF0:![0-9]+]] +; +entry: + %cmp15 = icmp eq i32 %n, 0 + br i1 %cmp15, label %for.cond.cleanup, label %for.body + +for.cond.cleanup: ; preds = %for.body, %entry + %x.0.lcssa = phi double [ 0.000000e+00, %entry ], [ %add, %for.body ] + %y.0.lcssa = phi double [ 0.000000e+00, %entry ], [ %add4, %for.body ] + %mul = fmul double %x.0.lcssa, %y.0.lcssa + ret double %mul + +for.body: ; preds = %entry, %for.body + %i.018 = phi i32 [ %add5, %for.body ], [ 0, %entry ] + %y.017 = phi double [ %add4, %for.body ], [ 0.000000e+00, %entry ] + %x.016 = phi double [ %add, %for.body ], [ 0.000000e+00, %entry ] + %idxprom = zext i32 %i.018 to i64 + %arrayidx = getelementptr inbounds double, ptr %a, i64 %idxprom + %0 = load double, ptr %arrayidx, align 8 + %add = fadd double %x.016, %0 + %add1 = or disjoint i32 %i.018, 1 + %idxprom2 = zext i32 %add1 to i64 + %arrayidx3 = getelementptr inbounds double, ptr %a, i64 %idxprom2 + %1 = load double, ptr %arrayidx3, align 8 + %add4 = fadd double %y.017, %1 + %add5 = add i32 %i.018, 2 + %cmp = icmp ult i32 %add5, %n + br i1 %cmp, label %for.body, label %for.cond.cleanup, !prof !0 +} + +!0 = !{!"branch_weights", i32 12, i32 1}