[PATCH] D125110: [SLP][NFC] Precommit a lit test for a followup patch that improves tree reordering for external users.

Vasileios Porpodas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 6 11:23:59 PDT 2022


vporpo created this revision.
vporpo added reviewers: ABataev, RKSimon.
Herald added a project: All.
vporpo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125110

Files:
  llvm/test/Transforms/SLPVectorizer/X86/reorder_with_external_users.ll


Index: llvm/test/Transforms/SLPVectorizer/X86/reorder_with_external_users.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/SLPVectorizer/X86/reorder_with_external_users.ll
@@ -0,0 +1,52 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -slp-vectorizer -S -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7-avx | FileCheck %s
+
+; Make sure that we rotate the graph to help avoid the shuffle to
+; the external vectorizable stores.
+;
+; SLP starts vectorizing from the operands of the `fcmp` in bb2, then crosses
+; into bb1, vectorizing all the way to the broadcast load at the top.
+; The stores in bb1 are external to this tree, but they are vectorizable and are
+; in reverse order.
+define void @rotate_with_external_users(double *%A, double *%ptr) {
+; CHECK-LABEL: @rotate_with_external_users(
+; CHECK-NEXT:  bb1:
+; CHECK-NEXT:    [[LD:%.*]] = load double, double* undef, align 8
+; CHECK-NEXT:    [[TMP0:%.*]] = insertelement <2 x double> poison, double [[LD]], i32 0
+; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <2 x double> [[TMP0]], double [[LD]], i32 1
+; CHECK-NEXT:    [[TMP2:%.*]] = fadd <2 x double> [[TMP1]], <double 1.100000e+00, double 2.200000e+00>
+; CHECK-NEXT:    [[TMP3:%.*]] = fmul <2 x double> [[TMP2]], <double 1.100000e+00, double 2.200000e+00>
+; CHECK-NEXT:    [[PTRA1:%.*]] = getelementptr inbounds double, double* [[A:%.*]], i64 0
+; CHECK-NEXT:    [[SHUFFLE:%.*]] = shufflevector <2 x double> [[TMP3]], <2 x double> poison, <2 x i32> <i32 1, i32 0>
+; CHECK-NEXT:    [[TMP4:%.*]] = bitcast double* [[PTRA1]] to <2 x double>*
+; CHECK-NEXT:    store <2 x double> [[SHUFFLE]], <2 x double>* [[TMP4]], align 8
+; CHECK-NEXT:    br label [[BB2:%.*]]
+; CHECK:       bb2:
+; CHECK-NEXT:    [[TMP5:%.*]] = fadd <2 x double> [[TMP3]], <double 3.300000e+00, double 4.400000e+00>
+; CHECK-NEXT:    [[TMP6:%.*]] = extractelement <2 x double> [[TMP5]], i32 0
+; CHECK-NEXT:    [[TMP7:%.*]] = extractelement <2 x double> [[TMP5]], i32 1
+; CHECK-NEXT:    [[SEED:%.*]] = fcmp ogt double [[TMP6]], [[TMP7]]
+; CHECK-NEXT:    ret void
+;
+bb1:
+  %ld = load double, double* undef
+
+  %add1 = fadd double %ld, 1.1
+  %add2 = fadd double %ld, 2.2
+
+  %mul1 = fmul double %add1, 1.1
+  %mul2 = fmul double %add2, 2.2
+
+  ; Thes are external vectorizable stores with operands in reverse order.
+  %ptrA1 = getelementptr inbounds double, double* %A, i64 0
+  %ptrA2 = getelementptr inbounds double, double* %A, i64 1
+  store double %mul2, double *%ptrA1
+  store double %mul1, double *%ptrA2
+  br label %bb2
+
+bb2:
+  %add3 = fadd double %mul1, 3.3
+  %add4 = fadd double %mul2, 4.4
+  %seed = fcmp ogt double %add3, %add4
+  ret void
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125110.427687.patch
Type: text/x-patch
Size: 2763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220506/7b1fa032/attachment.bin>


More information about the llvm-commits mailing list