-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[VP] Detect truncated and shifted EVLs during expansion #154334
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
lukel97
wants to merge
3
commits into
llvm:main
Choose a base branch
from
lukel97:expand-vp-discard-evl-trunc-shl
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 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
107 changes: 107 additions & 0 deletions
107
llvm/test/Transforms/PreISelIntrinsicLowering/expand-vp-convert-evl.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,107 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
| ; RUN: opt -passes=pre-isel-intrinsic-lowering -expandvp-override-evl-transform=Convert -expandvp-override-mask-transform=Legal -S < %s | FileCheck %s | ||
|
|
||
| define <vscale x 2 x i64> @unknown_evl(<vscale x 2 x i64> %x, <vscale x 2 x i64> %y, <vscale x 2 x i1> %m, i32 %evl) { | ||
| ; CHECK-LABEL: define <vscale x 2 x i64> @unknown_evl( | ||
| ; CHECK-SAME: <vscale x 2 x i64> [[X:%.*]], <vscale x 2 x i64> [[Y:%.*]], <vscale x 2 x i1> [[M:%.*]], i32 [[EVL:%.*]]) { | ||
| ; CHECK-NEXT: [[TMP1:%.*]] = call <vscale x 2 x i1> @llvm.get.active.lane.mask.nxv2i1.i32(i32 0, i32 [[EVL]]) | ||
| ; CHECK-NEXT: [[TMP2:%.*]] = and <vscale x 2 x i1> [[TMP1]], [[M]] | ||
| ; CHECK-NEXT: [[VSCALE:%.*]] = call i32 @llvm.vscale.i32() | ||
| ; CHECK-NEXT: [[SCALABLE_SIZE:%.*]] = mul nuw i32 [[VSCALE]], 2 | ||
| ; CHECK-NEXT: [[ADD:%.*]] = call <vscale x 2 x i64> @llvm.vp.add.nxv2i64(<vscale x 2 x i64> poison, <vscale x 2 x i64> poison, <vscale x 2 x i1> [[TMP2]], i32 [[SCALABLE_SIZE]]) | ||
| ; CHECK-NEXT: ret <vscale x 2 x i64> [[ADD]] | ||
| ; | ||
| %add = call <vscale x 2 x i64> @llvm.vp.add(<vscale x 2 x i64> poison, <vscale x 2 x i64> poison, <vscale x 2 x i1> %m, i32 %evl) | ||
| ret <vscale x 2 x i64> %add | ||
| } | ||
|
|
||
| define <2 x i64> @exact_evl_fixed(<2 x i64> %x, <2 x i64> %y, <2 x i1> %m) { | ||
| ; CHECK-LABEL: define <2 x i64> @exact_evl_fixed( | ||
| ; CHECK-SAME: <2 x i64> [[X:%.*]], <2 x i64> [[Y:%.*]], <2 x i1> [[M:%.*]]) { | ||
| ; CHECK-NEXT: [[ADD:%.*]] = call <2 x i64> @llvm.vp.add.v2i64(<2 x i64> poison, <2 x i64> poison, <2 x i1> [[M]], i32 2) | ||
| ; CHECK-NEXT: ret <2 x i64> [[ADD]] | ||
| ; | ||
| %add = call <2 x i64> @llvm.vp.add(<2 x i64> poison, <2 x i64> poison, <2 x i1> %m, i32 2) | ||
| ret <2 x i64> %add | ||
| } | ||
|
|
||
| define <vscale x 2 x i64> @exact_evl_vscale_mul(<vscale x 2 x i64> %x, <vscale x 2 x i64> %y, <vscale x 2 x i1> %m) { | ||
| ; CHECK-LABEL: define <vscale x 2 x i64> @exact_evl_vscale_mul( | ||
| ; CHECK-SAME: <vscale x 2 x i64> [[X:%.*]], <vscale x 2 x i64> [[Y:%.*]], <vscale x 2 x i1> [[M:%.*]]) { | ||
| ; CHECK-NEXT: [[VSCALE:%.*]] = call i32 @llvm.vscale.i32() | ||
| ; CHECK-NEXT: [[EVL:%.*]] = mul i32 [[VSCALE]], 2 | ||
| ; CHECK-NEXT: [[ADD:%.*]] = call <vscale x 2 x i64> @llvm.vp.add.nxv2i64(<vscale x 2 x i64> poison, <vscale x 2 x i64> poison, <vscale x 2 x i1> [[M]], i32 [[EVL]]) | ||
| ; CHECK-NEXT: ret <vscale x 2 x i64> [[ADD]] | ||
| ; | ||
| %vscale = call i32 @llvm.vscale() | ||
| %evl = mul i32 %vscale, 2 | ||
| %add = call <vscale x 2 x i64> @llvm.vp.add(<vscale x 2 x i64> poison, <vscale x 2 x i64> poison, <vscale x 2 x i1> %m, i32 %evl) | ||
| ret <vscale x 2 x i64> %add | ||
| } | ||
|
|
||
| define <vscale x 2 x i64> @exact_evl_vscale_shl(<vscale x 2 x i64> %x, <vscale x 2 x i64> %y, <vscale x 2 x i1> %m) { | ||
| ; CHECK-LABEL: define <vscale x 2 x i64> @exact_evl_vscale_shl( | ||
| ; CHECK-SAME: <vscale x 2 x i64> [[X:%.*]], <vscale x 2 x i64> [[Y:%.*]], <vscale x 2 x i1> [[M:%.*]]) { | ||
| ; CHECK-NEXT: [[VSCALE:%.*]] = call i32 @llvm.vscale.i32() | ||
| ; CHECK-NEXT: [[EVL:%.*]] = shl i32 [[VSCALE]], 1 | ||
| ; CHECK-NEXT: [[ADD:%.*]] = call <vscale x 2 x i64> @llvm.vp.add.nxv2i64(<vscale x 2 x i64> poison, <vscale x 2 x i64> poison, <vscale x 2 x i1> [[M]], i32 [[EVL]]) | ||
| ; CHECK-NEXT: ret <vscale x 2 x i64> [[ADD]] | ||
| ; | ||
| %vscale = call i32 @llvm.vscale() | ||
| %evl = shl i32 %vscale, 1 | ||
| %add = call <vscale x 2 x i64> @llvm.vp.add(<vscale x 2 x i64> poison, <vscale x 2 x i64> poison, <vscale x 2 x i1> %m, i32 %evl) | ||
| ret <vscale x 2 x i64> %add | ||
| } | ||
|
|
||
| define <vscale x 2 x i64> @exact_evl_vscale_mul_trunc(<vscale x 2 x i64> %x, <vscale x 2 x i64> %y, <vscale x 2 x i1> %m) { | ||
| ; CHECK-LABEL: define <vscale x 2 x i64> @exact_evl_vscale_mul_trunc( | ||
| ; CHECK-SAME: <vscale x 2 x i64> [[X:%.*]], <vscale x 2 x i64> [[Y:%.*]], <vscale x 2 x i1> [[M:%.*]]) { | ||
| ; CHECK-NEXT: [[VSCALE:%.*]] = call i64 @llvm.vscale.i64() | ||
| ; CHECK-NEXT: [[SHL:%.*]] = mul i64 [[VSCALE]], 2 | ||
| ; CHECK-NEXT: [[EVL:%.*]] = trunc nuw i64 [[SHL]] to i32 | ||
| ; CHECK-NEXT: [[ADD:%.*]] = call <vscale x 2 x i64> @llvm.vp.add.nxv2i64(<vscale x 2 x i64> poison, <vscale x 2 x i64> poison, <vscale x 2 x i1> [[M]], i32 [[EVL]]) | ||
| ; CHECK-NEXT: ret <vscale x 2 x i64> [[ADD]] | ||
| ; | ||
| %vscale = call i64 @llvm.vscale() | ||
| %shl = mul i64 %vscale, 2 | ||
| %evl = trunc nuw i64 %shl to i32 | ||
| %add = call <vscale x 2 x i64> @llvm.vp.add(<vscale x 2 x i64> poison, <vscale x 2 x i64> poison, <vscale x 2 x i1> %m, i32 %evl) | ||
| ret <vscale x 2 x i64> %add | ||
| } | ||
|
|
||
|
|
||
| define <vscale x 2 x i64> @exact_evl_vscale_shl_trunc(<vscale x 2 x i64> %x, <vscale x 2 x i64> %y, <vscale x 2 x i1> %m) { | ||
| ; CHECK-LABEL: define <vscale x 2 x i64> @exact_evl_vscale_shl_trunc( | ||
| ; CHECK-SAME: <vscale x 2 x i64> [[X:%.*]], <vscale x 2 x i64> [[Y:%.*]], <vscale x 2 x i1> [[M:%.*]]) { | ||
| ; CHECK-NEXT: [[VSCALE:%.*]] = call i64 @llvm.vscale.i64() | ||
| ; CHECK-NEXT: [[SHL:%.*]] = shl i64 [[VSCALE]], 1 | ||
| ; CHECK-NEXT: [[EVL:%.*]] = trunc nuw i64 [[SHL]] to i32 | ||
| ; CHECK-NEXT: [[ADD:%.*]] = call <vscale x 2 x i64> @llvm.vp.add.nxv2i64(<vscale x 2 x i64> poison, <vscale x 2 x i64> poison, <vscale x 2 x i1> [[M]], i32 [[EVL]]) | ||
| ; CHECK-NEXT: ret <vscale x 2 x i64> [[ADD]] | ||
| ; | ||
| %vscale = call i64 @llvm.vscale() | ||
| %shl = shl i64 %vscale, 1 | ||
| %evl = trunc nuw i64 %shl to i32 | ||
| %add = call <vscale x 2 x i64> @llvm.vp.add(<vscale x 2 x i64> poison, <vscale x 2 x i64> poison, <vscale x 2 x i1> %m, i32 %evl) | ||
| ret <vscale x 2 x i64> %add | ||
| } | ||
|
|
||
| define <vscale x 2 x i64> @exact_evl_vscale_shl_trunc_no_nuw(<vscale x 2 x i64> %x, <vscale x 2 x i64> %y, <vscale x 2 x i1> %m) { | ||
| ; CHECK-LABEL: define <vscale x 2 x i64> @exact_evl_vscale_shl_trunc_no_nuw( | ||
| ; CHECK-SAME: <vscale x 2 x i64> [[X:%.*]], <vscale x 2 x i64> [[Y:%.*]], <vscale x 2 x i1> [[M:%.*]]) { | ||
| ; CHECK-NEXT: [[VSCALE:%.*]] = call i64 @llvm.vscale.i64() | ||
| ; CHECK-NEXT: [[SHL:%.*]] = shl i64 [[VSCALE]], 1 | ||
| ; CHECK-NEXT: [[EVL:%.*]] = trunc i64 [[SHL]] to i32 | ||
| ; CHECK-NEXT: [[TMP1:%.*]] = call <vscale x 2 x i1> @llvm.get.active.lane.mask.nxv2i1.i32(i32 0, i32 [[EVL]]) | ||
| ; CHECK-NEXT: [[TMP2:%.*]] = and <vscale x 2 x i1> [[TMP1]], [[M]] | ||
| ; CHECK-NEXT: [[VSCALE1:%.*]] = call i32 @llvm.vscale.i32() | ||
| ; CHECK-NEXT: [[SCALABLE_SIZE:%.*]] = mul nuw i32 [[VSCALE1]], 2 | ||
| ; CHECK-NEXT: [[ADD:%.*]] = call <vscale x 2 x i64> @llvm.vp.add.nxv2i64(<vscale x 2 x i64> poison, <vscale x 2 x i64> poison, <vscale x 2 x i1> [[TMP2]], i32 [[SCALABLE_SIZE]]) | ||
| ; CHECK-NEXT: ret <vscale x 2 x i64> [[ADD]] | ||
| ; | ||
| %vscale = call i64 @llvm.vscale() | ||
| %shl = shl i64 %vscale, 1 | ||
| %evl = trunc i64 %shl to i32 | ||
| %add = call <vscale x 2 x i64> @llvm.vp.add(<vscale x 2 x i64> poison, <vscale x 2 x i64> poison, <vscale x 2 x i1> %m, i32 %evl) | ||
| ret <vscale x 2 x i64> %add | ||
| } |
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.
Do we need to check for NUW on the Mul too?