[PATCH] D142589: [LV] Perform recurrence sinking directly on VPlan.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 13 09:19:55 PST 2023


fhahn added a comment.

In D142589#4123383 <https://reviews.llvm.org/D142589#4123383>, @ashay-github wrote:

> @fhahn, This patch is causing a Windows Debug build (with VS 2022 MSVC 19.34.31937) of opt to crash for the llvm\test\Transforms\LoopVectorize\first-order-recurrence-sink-replicate-region.ll test (see stack trace below).  Sadly, the fix in commit af3c25dc <https://reviews.llvm.org/rGaf3c25dc3d871a7665610a819426c31d5eb17a03> does not resolve the problem.  I (locally) reverted this patch and validated that the crash is resolved.
>
> Here is a partial stack trace.  Could you revert / fix this crash soon?
>
>   0.      Program arguments: build\bin\opt.exe -passes=loop-vectorize -force-vector-width=2 -force-vector-interleave=1 -force-widen-divrem-via-safe-divisor=0 -disable-output -debug-only=loop-vectorize llvm\test\Transforms\LoopVectorize\first-order-recurrence-sink-replicate-region.ll
>   
>   Exception Code: 0x80000003
>   
>    #0 0x00007ff60564a39a std::_Debug_lt_pred<`sinkRecurrenceUsersAfterPrevious'::`2'::<lambda_2> &,llvm::VPRecipeBase * &,llvm::VPRecipeBase * &,0> C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\include\xutility:1096:0
>   
>    #1 0x00007ff60564b8da std::_Insertion_sort_unchecked<llvm::VPRecipeBase * *,`sinkRecurrenceUsersAfterPrevious'::`2'::<lambda_2> > C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\include\algorithm:7519:0
>   
>    #2 0x00007ff60564c82d std::_Sort_unchecked<llvm::VPRecipeBase * *,`sinkRecurrenceUsersAfterPrevious'::`2'::<lambda_2> > C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\include\algorithm:7640:0
>   
>    #3 0x00007ff605650b39 std::sort<llvm::VPRecipeBase * *,`sinkRecurrenceUsersAfterPrevious'::`2'::<lambda_2> > C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\include\algorithm:7670:0
>   
>    #4 0x00007ff605650aa8 llvm::sort<llvm::VPRecipeBase * *,`sinkRecurrenceUsersAfterPrevious'::`2'::<lambda_2> > llvm-project\llvm\include\llvm\ADT\STLExtras.h:1706:0
>   
>    #5 0x00007ff605650a61 llvm::sort<llvm::SmallVector<llvm::VPRecipeBase *,6> &,`sinkRecurrenceUsersAfterPrevious'::`2'::<lambda_2> > llvm-project\llvm\include\llvm\ADT\STLExtras.h:1711:0
>   
>    #6 0x00007ff6056448c3 sinkRecurrenceUsersAfterPrevious llvm-project\llvm\lib\Transforms\Vectorize\VPlanTransforms.cpp:619:0
>   
>    ...

Thanks for the report. This seems to only show up on Windows, so I cannot reproduce this locally.

I *think* I've seen similar issues in the past, could you try to see if the following patch fixes the issue:

  diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
  index 10a67081a0d0..ddbd27223044 100644
  --- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
  +++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
  @@ -612,7 +612,7 @@ sinkRecurrenceUsersAfterPrevious(VPFirstOrderRecurrencePHIRecipe *FOR,
  
     // Keep recipes to sink ordered by dominance so earlier instructions are
     // processed first.
  -  sort(WorkList, [&VPDT](const VPRecipeBase *A, const VPRecipeBase *B) {
  +  stable_sort(WorkList, [&VPDT](const VPRecipeBase *A, const VPRecipeBase *B) {
       return dominates(A, B, VPDT);
     });
  ```?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142589/new/

https://reviews.llvm.org/D142589



More information about the llvm-commits mailing list