[PATCH] D75746: [LoopVectorizer] Simplify branch in the remainder loop for trivial cases

Danila Malyutin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 6 07:41:54 PST 2020


danilaml created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
danilaml marked an inline comment as done.
danilaml added inline comments.


================
Comment at: llvm/test/Transforms/LoopVectorize/if-pred-stores.ll:278
 ; VEC-NEXT:    call void @llvm.assume(i1 [[TMP0]])
-; VEC-NEXT:    br label [[FOR_BODY14:%.*]]
-; VEC:       for.body14:
-; VEC-NEXT:    [[INDVARS_IV3:%.*]] = phi i64 [ [[INDVARS_IV_NEXT4:%.*]], [[FOR_INC23:%.*]] ], [ undef, [[ENTRY:%.*]] ]
-; VEC-NEXT:    [[INEWCHUNKS_120:%.*]] = phi i32 [ [[INEWCHUNKS_2:%.*]], [[FOR_INC23]] ], [ undef, [[ENTRY]] ]
-; VEC-NEXT:    [[ARRAYIDX16:%.*]] = getelementptr inbounds [768 x i32], [768 x i32]* undef, i64 0, i64 [[INDVARS_IV3]]
-; VEC-NEXT:    [[TMP:%.*]] = load i32, i32* [[ARRAYIDX16]], align 4
-; VEC-NEXT:    br i1 undef, label [[IF_THEN18:%.*]], label [[FOR_INC23]]
-; VEC:       if.then18:
-; VEC-NEXT:    store i32 2, i32* [[ARRAYIDX16]], align 4
-; VEC-NEXT:    [[INC21:%.*]] = add nsw i32 [[INEWCHUNKS_120]], 1
-; VEC-NEXT:    br label [[FOR_INC23]]
-; VEC:       for.inc23:
-; VEC-NEXT:    [[INEWCHUNKS_2]] = phi i32 [ [[INC21]], [[IF_THEN18]] ], [ [[INEWCHUNKS_120]], [[FOR_BODY14]] ]
-; VEC-NEXT:    [[INDVARS_IV_NEXT4]] = add nsw i64 [[INDVARS_IV3]], 1
-; VEC-NEXT:    [[TMP1:%.*]] = trunc i64 [[INDVARS_IV3]] to i32
-; VEC-NEXT:    [[CMP13:%.*]] = icmp slt i32 [[TMP1]], 0
-; VEC-NEXT:    call void @llvm.assume(i1 [[CMP13]])
-; VEC-NEXT:    br label [[FOR_BODY14]]
+; VEC-NEXT:    unreachable
 ;
----------------
this transform seems correct, but not sure if the original purpose of this test is still fulfilled


When vectorizing by factor of 2 the remainder loop always executes
only one iteration so there is no actual need to keep the branch.

Fixes PR44547


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75746

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Transforms/LoopVectorize/ARM/sphinx.ll
  llvm/test/Transforms/LoopVectorize/SystemZ/predicated-first-order-recurrence.ll
  llvm/test/Transforms/LoopVectorize/if-pred-stores.ll
  llvm/test/Transforms/LoopVectorize/pr44547.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75746.248728.patch
Type: text/x-patch
Size: 15358 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200306/738316f0/attachment.bin>


More information about the llvm-commits mailing list