-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand fuzz_simplify coverage for shuffle, lane-extraction, and vector-reduction expressions
#9034
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
Changes from all commits
f52dfa6
c005204
f58e21d
1ffb505
73a0e55
76a29cd
215bbe8
ce8cf94
329e7b1
e73ab4c
088466a
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 |
|---|---|---|
|
|
@@ -83,7 +83,8 @@ Expr Simplify::visit(const Cast *op, ExprInfo *info) { | |
| return make_const(op->type, safe_numeric_cast<double>(*u), info); | ||
| } else if (cast && | ||
| op->type.code() == cast->type.code() && | ||
| op->type.bits() < cast->type.bits()) { | ||
| op->type.bits() < cast->type.bits() && | ||
| op->type.lanes() == cast->value.type().lanes()) { | ||
| // If this is a cast of a cast of the same type, where the | ||
| // outer cast is narrower, the inner cast can be | ||
| // eliminated. | ||
|
|
@@ -93,7 +94,8 @@ Expr Simplify::visit(const Cast *op, ExprInfo *info) { | |
| cast->type.is_int() && | ||
| cast->value.type().is_int() && | ||
| op->type.bits() >= cast->type.bits() && | ||
| cast->type.bits() >= cast->value.type().bits()) { | ||
| cast->type.bits() >= cast->value.type().bits() && | ||
| op->type.lanes() == cast->value.type().lanes()) { | ||
|
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. Same |
||
| // Casting from a signed type always sign-extends, so widening | ||
| // partway to a signed type and the rest of the way to some other | ||
| // integer type is the same as just widening to that integer type | ||
|
|
@@ -103,7 +105,8 @@ Expr Simplify::visit(const Cast *op, ExprInfo *info) { | |
| op->type.is_int_or_uint() && | ||
| cast->type.is_int_or_uint() && | ||
| op->type.bits() <= cast->type.bits() && | ||
| op->type.bits() <= op->value.type().bits()) { | ||
| op->type.bits() <= op->value.type().bits() && | ||
| op->type.lanes() == cast->value.type().lanes()) { | ||
|
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. Same |
||
| // If this is a cast between integer types, where the | ||
| // outer cast is narrower than the inner cast and the | ||
| // inner cast's argument, the inner cast can be | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -137,7 +137,7 @@ Expr Simplify::visit(const VectorReduce *op, ExprInfo *info) { | |
| rewrite(h_min(max(broadcast(x, arg_lanes), y), lanes), max(h_min(y, lanes), broadcast(x, lanes))) || | ||
| rewrite(h_min(broadcast(x, arg_lanes), lanes), broadcast(x, lanes)) || | ||
| rewrite(h_min(broadcast(x, c0), lanes), h_min(x, lanes), factor % c0 == 0) || | ||
| rewrite(h_min(ramp(x, y, arg_lanes), lanes), x + min(y * (arg_lanes - 1), 0)) || | ||
| ((lanes == 1) && rewrite(h_min(ramp(x, y, arg_lanes), lanes), x + min(y * (arg_lanes - 1), 0))) || | ||
|
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. Will cause merge conflict with #8629, we should just merge that first. |
||
| false) { | ||
| return mutate(rewrite.result, info); | ||
| } | ||
|
|
@@ -151,7 +151,7 @@ Expr Simplify::visit(const VectorReduce *op, ExprInfo *info) { | |
| rewrite(h_max(max(broadcast(x, arg_lanes), y), lanes), max(h_max(y, lanes), broadcast(x, lanes))) || | ||
| rewrite(h_max(broadcast(x, arg_lanes), lanes), broadcast(x, lanes)) || | ||
| rewrite(h_max(broadcast(x, c0), lanes), h_max(x, lanes), factor % c0 == 0) || | ||
| rewrite(h_max(ramp(x, y, arg_lanes), lanes), x + max(y * (arg_lanes - 1), 0)) || | ||
| ((lanes == 1) && rewrite(h_max(ramp(x, y, arg_lanes), lanes), x + max(y * (arg_lanes - 1), 0))) || | ||
| false) { | ||
| return mutate(rewrite.result, info); | ||
| } | ||
|
|
@@ -165,14 +165,14 @@ Expr Simplify::visit(const VectorReduce *op, ExprInfo *info) { | |
| rewrite(h_and(broadcast(x, arg_lanes) && y, lanes), h_and(y, lanes) && broadcast(x, lanes)) || | ||
| rewrite(h_and(broadcast(x, arg_lanes), lanes), broadcast(x, lanes)) || | ||
| rewrite(h_and(broadcast(x, c0), lanes), h_and(x, lanes), factor % c0 == 0) || | ||
| rewrite(h_and(ramp(x, y, arg_lanes) < broadcast(z, arg_lanes), lanes), | ||
| x + max(y * (arg_lanes - 1), 0) < z) || | ||
| rewrite(h_and(ramp(x, y, arg_lanes) <= broadcast(z, arg_lanes), lanes), | ||
| x + max(y * (arg_lanes - 1), 0) <= z) || | ||
| rewrite(h_and(broadcast(x, arg_lanes) < ramp(y, z, arg_lanes), lanes), | ||
| x < y + min(z * (arg_lanes - 1), 0)) || | ||
| rewrite(h_and(broadcast(x, arg_lanes) < ramp(y, z, arg_lanes), lanes), | ||
| x <= y + min(z * (arg_lanes - 1), 0)) || | ||
| ((lanes == 1) && rewrite(h_and(ramp(x, y, arg_lanes) < broadcast(z, arg_lanes), lanes), | ||
| x + max(y * (arg_lanes - 1), 0) < z)) || | ||
| ((lanes == 1) && rewrite(h_and(ramp(x, y, arg_lanes) <= broadcast(z, arg_lanes), lanes), | ||
| x + max(y * (arg_lanes - 1), 0) <= z)) || | ||
| ((lanes == 1) && rewrite(h_and(broadcast(x, arg_lanes) < ramp(y, z, arg_lanes), lanes), | ||
| x < y + min(z * (arg_lanes - 1), 0))) || | ||
| ((lanes == 1) && rewrite(h_and(broadcast(x, arg_lanes) < ramp(y, z, arg_lanes), lanes), | ||
| x <= y + min(z * (arg_lanes - 1), 0))) || | ||
| false) { | ||
| return mutate(rewrite.result, info); | ||
| } | ||
|
|
@@ -187,14 +187,14 @@ Expr Simplify::visit(const VectorReduce *op, ExprInfo *info) { | |
| rewrite(h_or(broadcast(x, arg_lanes), lanes), broadcast(x, lanes)) || | ||
| rewrite(h_or(broadcast(x, c0), lanes), h_or(x, lanes), factor % c0 == 0) || | ||
| // type of arg_lanes is somewhat indeterminate | ||
| rewrite(h_or(ramp(x, y, arg_lanes) < broadcast(z, arg_lanes), lanes), | ||
| x + min(y * (arg_lanes - 1), 0) < z) || | ||
| rewrite(h_or(ramp(x, y, arg_lanes) <= broadcast(z, arg_lanes), lanes), | ||
| x + min(y * (arg_lanes - 1), 0) <= z) || | ||
| rewrite(h_or(broadcast(x, arg_lanes) < ramp(y, z, arg_lanes), lanes), | ||
| x < y + max(z * (arg_lanes - 1), 0)) || | ||
| rewrite(h_or(broadcast(x, arg_lanes) < ramp(y, z, arg_lanes), lanes), | ||
| x <= y + max(z * (arg_lanes - 1), 0)) || | ||
| ((lanes == 1) && rewrite(h_or(ramp(x, y, arg_lanes) < broadcast(z, arg_lanes), lanes), | ||
| x + min(y * (arg_lanes - 1), 0) < z)) || | ||
| ((lanes == 1) && rewrite(h_or(ramp(x, y, arg_lanes) <= broadcast(z, arg_lanes), lanes), | ||
| x + min(y * (arg_lanes - 1), 0) <= z)) || | ||
| ((lanes == 1) && rewrite(h_or(broadcast(x, arg_lanes) < ramp(y, z, arg_lanes), lanes), | ||
| x < y + max(z * (arg_lanes - 1), 0))) || | ||
| ((lanes == 1) && rewrite(h_or(broadcast(x, arg_lanes) < ramp(y, z, arg_lanes), lanes), | ||
| x <= y + max(z * (arg_lanes - 1), 0))) || | ||
| false) { | ||
| return mutate(rewrite.result, info); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -236,7 +236,7 @@ Expr Simplify::visit(const Shuffle *op, ExprInfo *info) { | |
| } | ||
| } | ||
| if (can_collapse) { | ||
| return Ramp::make(r->base, r->stride, op->indices.size()); | ||
| return mutate(Ramp::make(r->base, r->stride, op->indices.size()), info); | ||
|
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. r was already simplified, this just gives it more lanes. Was there a case here where that made further simplification possible? I.e. was this an idempotence failure? |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -257,7 +257,7 @@ Expr Simplify::visit(const Shuffle *op, ExprInfo *info) { | |
| } | ||
|
|
||
| if (can_collapse) { | ||
| return Ramp::make(new_vectors[0], stride, op->indices.size()); | ||
| return mutate(Ramp::make(new_vectors[0], stride, op->indices.size()), info); | ||
| } | ||
| } | ||
| } | ||
|
|
||
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.
This is wrong. It's impossible to construct a cast where this is true.