
This patch marks the induction increment of the main induction variable of the vector loop as NUW when not folding the tail. If the tail is not folded, we know that End - Start >= Step (either statically or through the minimum iteration checks). We also know that both Start % Step == 0 and End % Step == 0. We exit the vector loop if %IV + %Step == %End. Hence we must exit the loop before %IV + %Step unsigned overflows and we can mark the induction increment as NUW. This should make SCEV return more precise bounds for the created vector loops, used by later optimizations, like late unrolling. At the moment quite a few tests still need to be updated, but before doing so I'd like to get initial feedback to make sure I am not missing anything. Note that this could probably be further improved by using information from the original IV. Attempt of modeling of the assumption in Alive2: https://alive2.llvm.org/ce/z/H_DL_g Part of a set of fixes required for PR50412. Reviewed By: mkazantsev Differential Revision: https://reviews.llvm.org/D103255
24 lines
783 B
LLVM
24 lines
783 B
LLVM
; RUN: opt -loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S %s | FileCheck %s
|
|
|
|
; Avoid crashing while trying to vectorize fcmp that can be folded to vector of
|
|
; i1 true.
|
|
define void @test1() {
|
|
; CHECK-LABEL: test1(
|
|
; CHECK-LABEL: vector.body:
|
|
; CHECK-NEXT: %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
|
|
; CHECK: %index.next = add nuw i32 %index, 4
|
|
|
|
entry:
|
|
br label %loop
|
|
|
|
loop: ; preds = %loop, %entry
|
|
%iv = phi i32 [ 0, %entry ], [ %ivnext, %loop ]
|
|
%fcmp = fcmp uno float 0.000000e+00, 0.000000e+00
|
|
%ivnext = add nsw i32 %iv, 1
|
|
%cnd = icmp sgt i32 %iv, 142
|
|
br i1 %cnd, label %exit, label %loop
|
|
|
|
exit: ; preds = %loop
|
|
ret void
|
|
}
|