-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[InstCombine] Pull extract through broadcast #143380
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
Merged
nikic
merged 13 commits into
llvm:main
from
agorenstein-nvidia:instcombine-extract-through-broadcast
Jul 4, 2025
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
34c1222
Initial changes
agorenstein-nvidia 31cb512
Merge branch 'main' into instcombine-extract-through-broadcast
agorenstein-nvidia e315c89
PR feedback 1
agorenstein-nvidia 274cec9
clang-format
agorenstein-nvidia 4fda162
Fixing edit damage in test file
agorenstein-nvidia 5d9e4d9
Removed unneeded check
agorenstein-nvidia a1aec2e
Improve undef/poison usage in test (per PR automation failure), and u…
agorenstein-nvidia 70d3c01
Fixed varname convention per PR feedback; on reflection from PR feedb…
agorenstein-nvidia 52f5c4b
Restore old tests, reframe optimization as extension of existing one.
agorenstein-nvidia e21bde6
fix formatting errors, sorry
agorenstein-nvidia 09d5e4c
Improvement via optional from RKSimon's suggestion
agorenstein-nvidia ce809f6
Improved tests with semantic names per RKSimon's PR feedback
agorenstein-nvidia 21b8638
Improved comments to explicitly-named tests per PR suggestion
agorenstein-nvidia 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
54 changes: 54 additions & 0 deletions
54
llvm/test/Transforms/InstCombine/vec_extract_through_broadcast.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,54 @@ | ||
| ; RUN: opt -passes=instcombine -S < %s | FileCheck %s | ||
|
|
||
| define float @extract_from_zero_init_shuffle(<2 x float> %1, i64 %idx) { | ||
| ; CHECK-LABEL: @extract_from_zero_init_shuffle( | ||
| ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x float> [[W:%.*]], i64 0 | ||
| ; CHECK-NEXT: ret float [[TMP1]] | ||
| ; | ||
| %3 = shufflevector <2 x float> %1, <2 x float> poison, <4 x i32> zeroinitializer | ||
|
||
| %4 = extractelement <4 x float> %3, i64 %idx | ||
| ret float %4 | ||
| } | ||
|
|
||
|
|
||
| define float @extract_from_general_splat(<2 x float> %1, i64 %idx) { | ||
| ; CHECK-LABEL: @extract_from_general_splat( | ||
| ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x float> [[W:%.*]], i64 1 | ||
| ; CHECK-NEXT: ret float [[TMP1]] | ||
| ; | ||
| %3 = shufflevector <2 x float> %1, <2 x float> poison, <4 x i32> <i32 1, i32 1, i32 1, i32 1> | ||
| %4 = extractelement <4 x float> %3, i64 %idx | ||
| ret float %4 | ||
| } | ||
|
|
||
| define float @extract_from_general_scalable_splat(<vscale x 2 x float> %1, i64 %idx) { | ||
| ; CHECK-LABEL: @extract_from_general_scalable_splat( | ||
| ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <vscale x 2 x float> [[W:%.*]], i64 0 | ||
| ; CHECK-NEXT: ret float [[TMP1]] | ||
| ; | ||
| %3 = shufflevector <vscale x 2 x float> %1, <vscale x 2 x float> poison, <vscale x 4 x i32> zeroinitializer | ||
| %4 = extractelement <vscale x 4 x float> %3, i64 %idx | ||
| ret float %4 | ||
| } | ||
|
|
||
| define float @no_extract_from_general_no_splat_0(<2 x float> %1, i64 %idx) { | ||
| ; CHECK-LABEL: @no_extract_from_general_no_splat_0( | ||
| ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <2 x float> [[W:%.*]], <2 x float> poison, <4 x i32> <i32 poison, i32 1, i32 1, i32 1> | ||
| ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x float> [[TMP1]], i64 %idx | ||
| ; CHECK-NEXT: ret float [[TMP2]] | ||
| ; | ||
| %3 = shufflevector <2 x float> %1, <2 x float> poison, <4 x i32> <i32 poison, i32 1, i32 1, i32 1> | ||
| %4 = extractelement <4 x float> %3, i64 %idx | ||
| ret float %4 | ||
| } | ||
agorenstein-nvidia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| define float @no_extract_from_general_no_splat_1(<2 x float> %1, i64 %idx) { | ||
| ; CHECK-LABEL: @no_extract_from_general_no_splat_1( | ||
| ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <2 x float> [[W:%.*]], <2 x float> poison, <4 x i32> <i32 1, i32 poison, i32 1, i32 1> | ||
| ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x float> [[TMP1]], i64 %idx | ||
| ; CHECK-NEXT: ret float [[TMP2]] | ||
| ; | ||
| %3 = shufflevector <2 x float> %1, <2 x float> poison, <4 x i32> <i32 1, i32 poison, i32 1, i32 1> | ||
| %4 = extractelement <4 x float> %3, i64 %idx | ||
| ret float %4 | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.