-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix Vulkan interleave two vectors bug + Vector Legalization lowering pass #8629
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
base: main
Are you sure you want to change the base?
Changes from all commits
ac1969a
368eb9b
15311e1
cd51b72
238da93
f2a0e4f
f612af7
f49b33e
ec398ec
4f61830
2d3909f
c61a989
82c30f9
1f9d3be
73d9d3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -240,6 +240,9 @@ xcuserdata | |
| # NeoVim + clangd | ||
| .cache | ||
|
|
||
| # CCLS | ||
| .ccls-cache | ||
|
|
||
| # Emacs | ||
| tags | ||
| TAGS | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -299,6 +299,10 @@ class Deinterleaver : public IRGraphMutator { | |
| } else { | ||
|
|
||
| Type t = op->type.with_lanes(new_lanes); | ||
| internal_assert((op->type.lanes() - starting_lane + lane_stride - 1) / lane_stride == new_lanes) | ||
| << "Deinterleaving with lane stride " << lane_stride << " and staring lane " << starting_lane | ||
| << " for var of Type " << op->type << " to " << t << " drops lanes unexpectedly." | ||
| << " Deinterleaver probably recursed too deep into types of different lane count."; | ||
| if (external_lets.contains(op->name) && | ||
| starting_lane == 0 && | ||
| lane_stride == 2) { | ||
|
|
@@ -393,8 +397,12 @@ class Deinterleaver : public IRGraphMutator { | |
| int index = indices.front(); | ||
| for (const auto &i : op->vectors) { | ||
| if (index < i.type().lanes()) { | ||
| ScopedValue<int> lane(starting_lane, index); | ||
| return mutate(i); | ||
| if (i.type().lanes() == op->type.lanes()) { | ||
| ScopedValue<int> scoped_starting_lane(starting_lane, index); | ||
| return mutate(i); | ||
| } else { | ||
| return Shuffle::make(op->vectors, indices); | ||
| } | ||
| } | ||
| index -= i.type().lanes(); | ||
| } | ||
|
|
@@ -406,10 +414,18 @@ class Deinterleaver : public IRGraphMutator { | |
| }; | ||
|
|
||
| Expr deinterleave(Expr e, int starting_lane, int lane_stride, int new_lanes, const Scope<> &lets) { | ||
| debug(3) << "Deinterleave " | ||
| << "(start:" << starting_lane << ", stide:" << lane_stride << ", new_lanes:" << new_lanes << "): " | ||
| << e << " of Type: " << e.type() << "\n"; | ||
| Type original_type = e.type(); | ||
| e = substitute_in_all_lets(e); | ||
| Deinterleaver d(starting_lane, lane_stride, new_lanes, lets); | ||
| e = d.mutate(e); | ||
| e = common_subexpression_elimination(e); | ||
| Type final_type = e.type(); | ||
| int expected_lanes = (original_type.lanes() + lane_stride - starting_lane - 1) / lane_stride; | ||
| internal_assert(original_type.code() == final_type.code()) << "Underlying types not identical after interleaving."; | ||
| internal_assert(expected_lanes == final_type.lanes()) << "Number of lanes incorrect after interleaving: " << final_type.lanes() << "while expected was " << expected_lanes << "."; | ||
mcourteaux marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return simplify(e); | ||
| } | ||
|
|
||
|
|
@@ -420,12 +436,12 @@ Expr extract_odd_lanes(const Expr &e, const Scope<> &lets) { | |
|
|
||
| Expr extract_even_lanes(const Expr &e, const Scope<> &lets) { | ||
| internal_assert(e.type().lanes() % 2 == 0); | ||
| return deinterleave(e, 0, 2, (e.type().lanes() + 1) / 2, lets); | ||
| return deinterleave(e, 0, 2, e.type().lanes() / 2, lets); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the starting lane is zero, and there are 3 lanes total, shouldn't there be two lanes in the result?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, there's an assert that the number of lanes is even, never mind. |
||
| } | ||
|
|
||
| Expr extract_mod3_lanes(const Expr &e, int lane, const Scope<> &lets) { | ||
| internal_assert(e.type().lanes() % 3 == 0); | ||
| return deinterleave(e, lane, 3, (e.type().lanes() + 2) / 3, lets); | ||
| return deinterleave(e, lane, 3, e.type().lanes() / 3, lets); | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.