Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Loop Vectorizer triggers an assert "IsOrdered requires IsInLoop" #51482

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR52515
Status NEW
Importance P enhancement
Reported by Serguei Katkov (serguei.katkov@azul.com)
Reported on 2021-11-15 18:49:34 -0800
Last modified on 2021-11-18 19:26:26 -0800
Version trunk
Hardware PC Windows NT
CC david.green@arm.com, florian_hahn@apple.com, kerry.mclaughlin@arm.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
For the following reduced test case
===============================================
; ModuleID = 'bad.ll'
source_filename = "bad.ll"
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-none-linux-gnu"

define float @wombat() {
bb:
  br label %bb1

bb1:                                              ; preds = %bb9, %bb
  %tmp = phi i64 [ 0, %bb ], [ %tmp10, %bb9 ]
  %tmp2 = phi float [ 0.000000e+00, %bb ], [ %tmp4, %bb9 ]
  %tmp3 = phi i64 [ 0, %bb ], [ %tmp5, %bb9 ]
  %tmp4 = fadd float %tmp2, 1.000000e+00
  %tmp5 = add nsw i64 %tmp3, 1
  %tmp6 = icmp ult i64 %tmp, 65536
  br i1 %tmp6, label %bb9, label %bb7

bb7:                                              ; preds = %bb1
  %tmp8 = phi float [ %tmp4, %bb1 ]
  ret float %tmp8

bb9:                                              ; preds = %bb1
  %tmp10 = add nuw nsw i64 %tmp, 1
  br i1 false, label %bb11, label %bb1

bb11:                                             ; preds = %bb9
  %tmp12 = phi float [ %tmp4, %bb9 ]
  ret float %tmp12
}

!0 = !{!"function_entry_count", i64 32768}
===============================================
the following assert is triggered.

===============================================
> opt  -passes=loop-vectorize -S bad.ll
opt:
/localhome/skatkov/work/llvm/src/llvm/lib/Transforms/Vectorize/VPlan.h:1186:
llvm::VPReductionPHIRecipe::VPReductionPHIRecipe(llvm::PHINode*,
llvm::RecurrenceDescriptor&, llvm::VPValue&, bool, bool): Assertion
`(!IsOrdered || IsInLoop) && "IsOrdered requires IsInLoop"' failed.
===============================================
The current processing phi node is

%tmp2 = phi float [ 0.000000e+00, %bb ], [ %tmp4, %bb9 ]
Quuxplusone commented 3 years ago

Hi, I've created a proposed fix for this in https://reviews.llvm.org/D114002

Quuxplusone commented 3 years ago

Thanks a lot! I will check the fix on the original case soon.

Quuxplusone commented 3 years ago

confirmed that proposed patch fixes the my original bug.

Quuxplusone commented 3 years ago

Patch landed, should be this bug closed?