-
Notifications
You must be signed in to change notification settings - Fork 15k
[VPlan][LV] Add removeRedundantAndMasks to VPlanTransforms #163534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nasherm
wants to merge
7
commits into
llvm:main
Choose a base branch
from
nasherm:nashe/double-vs-int
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3c1ff1f
[Transforms] Add LoopNoOpElimination pass
nasherm 25f2443
Enable loop-noop-elim in test
nasherm f3ef02e
Code formatting
nasherm 3eed0a5
Move LoopNoOpElim logic to VPlan
nasherm 9f49a14
Enable VPlanTransforms::removeRedundantAndMasks
nasherm 484c684
Fix test crash
nasherm ee90878
Code formatting
nasherm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
llvm/test/Transforms/LoopVectorize/vplan-transforms-remove-redundant-masks.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6 | ||
| ; RUN: opt -S -passes=loop-vectorize -force-vector-width=2 < %s | FileCheck %s | ||
|
|
||
| define void @elim_no_op_and(i32 %N, ptr %A, i32 %val) { | ||
| ; CHECK-LABEL: define void @elim_no_op_and( | ||
| ; CHECK-SAME: i32 [[N:%.*]], ptr [[A:%.*]], i32 [[VAL:%.*]]) { | ||
| ; CHECK-NEXT: [[ENTRY:.*:]] | ||
| ; CHECK-NEXT: [[CMP16_NOT:%.*]] = icmp eq i32 [[N]], 0 | ||
| ; CHECK-NEXT: br i1 [[CMP16_NOT]], label %[[FOR_COND_CLEANUP:.*]], label %[[FOR_COND1_PREHEADER_LR_PH:.*]] | ||
| ; CHECK: [[FOR_COND1_PREHEADER_LR_PH]]: | ||
| ; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64 | ||
| ; CHECK-NEXT: [[FLATTEN_TRIPCOUNT:%.*]] = mul nuw i64 [[TMP0]], [[TMP0]] | ||
| ; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[FLATTEN_TRIPCOUNT]], 2 | ||
| ; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_SCEVCHECK:.*]] | ||
| ; CHECK: [[VECTOR_SCEVCHECK]]: | ||
| ; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[FLATTEN_TRIPCOUNT]], -1 | ||
| ; CHECK-NEXT: [[TMP2:%.*]] = icmp ugt i64 [[TMP1]], 4294967295 | ||
| ; CHECK-NEXT: br i1 [[TMP2]], label %[[SCALAR_PH]], label %[[VECTOR_PH:.*]] | ||
| ; CHECK: [[VECTOR_PH]]: | ||
| ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[FLATTEN_TRIPCOUNT]], 2 | ||
| ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[FLATTEN_TRIPCOUNT]], [[N_MOD_VF]] | ||
| ; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <2 x i32> poison, i32 [[VAL]], i64 0 | ||
| ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <2 x i32> [[BROADCAST_SPLATINSERT]], <2 x i32> poison, <2 x i32> zeroinitializer | ||
| ; CHECK-NEXT: br label %[[VECTOR_BODY:.*]] | ||
| ; CHECK: [[VECTOR_BODY]]: | ||
| ; CHECK-NEXT: [[TMP3:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ] | ||
| ; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds nuw i32, ptr [[A]], i64 [[TMP3]] | ||
| ; CHECK-NEXT: [[WIDE_LOAD:%.*]] = load <2 x i32>, ptr [[TMP4]], align 4 | ||
| ; CHECK-NEXT: [[TMP5:%.*]] = add <2 x i32> [[WIDE_LOAD]], [[BROADCAST_SPLAT]] | ||
| ; CHECK-NEXT: store <2 x i32> [[TMP5]], ptr [[TMP4]], align 4 | ||
| ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[TMP3]], 2 | ||
| ; CHECK-NEXT: [[TMP6:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]] | ||
| ; CHECK-NEXT: br i1 [[TMP6]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]] | ||
| ; CHECK: [[MIDDLE_BLOCK]]: | ||
| ; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i64 [[FLATTEN_TRIPCOUNT]], [[N_VEC]] | ||
| ; CHECK-NEXT: br i1 [[CMP_N]], label %[[FOR_COND_CLEANUP_LOOPEXIT:.*]], label %[[SCALAR_PH]] | ||
| ; CHECK: [[SCALAR_PH]]: | ||
| ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[FOR_COND1_PREHEADER_LR_PH]] ], [ 0, %[[VECTOR_SCEVCHECK]] ] | ||
| ; CHECK-NEXT: br label %[[FOR_COND1_PREHEADER:.*]] | ||
| ; CHECK: [[FOR_COND1_PREHEADER]]: | ||
| ; CHECK-NEXT: [[INDVAR18:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[INDVAR_NEXT19:%.*]], %[[FOR_COND1_PREHEADER]] ] | ||
| ; CHECK-NEXT: [[IDXPROM:%.*]] = and i64 [[INDVAR18]], 4294967295 | ||
| ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds nuw i32, ptr [[A]], i64 [[IDXPROM]] | ||
| ; CHECK-NEXT: [[TMP7:%.*]] = load i32, ptr [[ARRAYIDX]], align 4 | ||
| ; CHECK-NEXT: [[ADD5:%.*]] = add i32 [[TMP7]], [[VAL]] | ||
| ; CHECK-NEXT: store i32 [[ADD5]], ptr [[ARRAYIDX]], align 4 | ||
| ; CHECK-NEXT: [[INDVAR_NEXT19]] = add nuw i64 [[INDVAR18]], 1 | ||
| ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[INDVAR_NEXT19]], [[FLATTEN_TRIPCOUNT]] | ||
| ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label %[[FOR_COND_CLEANUP_LOOPEXIT]], label %[[FOR_COND1_PREHEADER]], !llvm.loop [[LOOP3:![0-9]+]] | ||
| ; CHECK: [[FOR_COND_CLEANUP_LOOPEXIT]]: | ||
| ; CHECK-NEXT: br label %[[FOR_COND_CLEANUP]] | ||
| ; CHECK: [[FOR_COND_CLEANUP]]: | ||
| ; CHECK-NEXT: ret void | ||
| ; | ||
| entry: | ||
| %cmp16.not = icmp eq i32 %N, 0 | ||
| br i1 %cmp16.not, label %for.cond.cleanup, label %for.cond1.preheader.lr.ph | ||
|
|
||
| for.cond1.preheader.lr.ph: ; preds = %entry | ||
| %0 = zext i32 %N to i64 | ||
| %flatten.tripcount = mul nuw i64 %0, %0 | ||
| br label %for.cond1.preheader | ||
|
|
||
| for.cond1.preheader: ; preds = %for.cond1.preheader.lr.ph, %for.cond1.preheader | ||
| %indvar18 = phi i64 [ 0, %for.cond1.preheader.lr.ph ], [ %indvar.next19, %for.cond1.preheader ] | ||
| %idxprom = and i64 %indvar18, 4294967295 | ||
| %arrayidx = getelementptr inbounds nuw i32, ptr %A, i64 %idxprom | ||
| %1 = load i32, ptr %arrayidx, align 4 | ||
| %add5 = add i32 %1, %val | ||
| store i32 %add5, ptr %arrayidx, align 4 | ||
| %indvar.next19 = add nuw i64 %indvar18, 1 | ||
| %exitcond.not = icmp eq i64 %indvar.next19, %flatten.tripcount | ||
| br i1 %exitcond.not, label %for.cond.cleanup.loopexit, label %for.cond1.preheader | ||
|
|
||
| for.cond.cleanup.loopexit: ; preds = %for.cond1.preheader | ||
| br label %for.cond.cleanup | ||
|
|
||
| for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry | ||
| ret void | ||
| } | ||
|
|
||
| ;. | ||
| ; CHECK: [[LOOP0]] = distinct !{[[LOOP0]], [[META1:![0-9]+]], [[META2:![0-9]+]]} | ||
| ; CHECK: [[META1]] = !{!"llvm.loop.isvectorized", i32 1} | ||
| ; CHECK: [[META2]] = !{!"llvm.loop.unroll.runtime.disable"} | ||
| ; CHECK: [[LOOP3]] = distinct !{[[LOOP3]], [[META1]]} | ||
| ;. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't be checking for the block by name, as it isn't guaranteed to work, e.g. if you have two loops in a function that are vectorized the scev check block of the second will have a number appended to its name, so this transform will fail to apply.
It's GeneratedRTChecks that's generating the check condition, and it has it in SCEVCheckCond, so I think probably you need to get that value here somehow.