[PATCH] D152871: [SLP] Fixes bug in ShuffleBuilder when duplicate entry already exists.

Vasileios Porpodas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 13 17:32:48 PDT 2023


vporpo created this revision.
vporpo added a reviewer: ABataev.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
vporpo requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead.
Herald added a project: LLVM.

For more details please check out the lit test: `X86/shufflebuilder-bug.ll`.

@abataev I am not sure this is the correct solution, but it seems to be fixing the bug.
Could you please take a look?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152871

Files:
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/test/Transforms/SLPVectorizer/X86/shufflebuilder-bug.ll


Index: llvm/test/Transforms/SLPVectorizer/X86/shufflebuilder-bug.ll
===================================================================
--- llvm/test/Transforms/SLPVectorizer/X86/shufflebuilder-bug.ll
+++ llvm/test/Transforms/SLPVectorizer/X86/shufflebuilder-bug.ll
@@ -10,9 +10,8 @@
 ; CHECK-NEXT:    [[TMP3:%.*]] = insertelement <2 x float> [[TMP2]], float [[VAL]], i32 1
 ; CHECK-NEXT:    [[TMP4:%.*]] = shufflevector <2 x float> [[TMP3]], <2 x float> poison, <4 x i32> <i32 0, i32 0, i32 1, i32 1>
 ; CHECK-NEXT:    [[TMP5:%.*]] = fadd <4 x float> [[TMP1]], [[TMP4]]
-; CHECK-NEXT:    [[TMP6:%.*]] = shufflevector <2 x float> [[TMP3]], <2 x float> poison, <4 x i32> zeroinitializer
-; CHECK-NEXT:    [[TMP7:%.*]] = fmul <4 x float> [[TMP5]], [[TMP6]]
-; CHECK-NEXT:    store <4 x float> [[TMP7]], ptr [[GEP0]], align 4
+; CHECK-NEXT:    [[TMP6:%.*]] = fmul <4 x float> [[TMP5]], [[TMP4]]
+; CHECK-NEXT:    store <4 x float> [[TMP6]], ptr [[GEP0]], align 4
 ; CHECK-NEXT:    ret void
 ;
   %vec_3 = extractelement <4 x float> %vec, i32 3
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -9760,7 +9760,7 @@
             Mask[I] = Entries.front()->findLaneForValue(V);
         }
         ShuffleBuilder.add(Entries.front()->VectorizedValue, Mask);
-        Res = ShuffleBuilder.finalize(E->ReuseShuffleIndices);
+        Res = ShuffleBuilder.finalize(std::nullopt);
         return Res;
       }
       if (!Resized) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152871.531124.patch
Type: text/x-patch
Size: 1602 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230614/287f843e/attachment.bin>


More information about the llvm-commits mailing list