-
Notifications
You must be signed in to change notification settings - Fork 638
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
[Codegen][GPU] Let integer range optimization narrow GPU computations to i32 #19473
base: main
Are you sure you want to change the base?
Conversation
be116ef
to
ffa5fc4
Compare
01736ba
to
a367857
Compare
ArrayRef<ArrayAttr> castAssumptions = ArrayRef( | ||
static_cast<const ArrayAttr *>(assumptions.data()), assumptions.size()); | ||
auto newOp = rewriter.create<Util::AssumeIntOp>(op.getLoc(), newArgs, | ||
castAssumptions); |
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.
Can you not just do rewriter.create<Util::AssumeIntOp>(op.getLoc(), newArgs, op.getAssumptions());
If not we can either just clone with new operands or add a new builder.
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.
There's a builder missing - and no really room to insert one
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.
wdym there is no room to add a new builder? Can't we add a builder that take ArrayRef<Value>
and ArrayAttr
as operands?
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.
... Yeah, might not be a bad idea, could add one.
compiler/src/iree/compiler/Dialect/Util/Transforms/OptimizeIntArithmetic.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Dialect/Util/Transforms/OptimizeIntArithmetic.cpp
Outdated
Show resolved
Hide resolved
a367857
to
09d7c2d
Compare
Note: This PR is stacked on top of #19372, and so looks bigger than it is. The relevant changes are in the last commit.
Add an option to -iree-util-optimize-int-arithmetic to have it perform computations in i32 where possible, which is enabled when optimizing arithmetic for GPU codegen. This allows LLVM co correctly conclude that various computations don't need to be done at full 64-bit precision, thus saving registers and instructions. (LLVM has some rewrites for this, but they're, for example, gated on only having one use of the potentially-truncated value, which means that shared math stays in an over-wide data type).