Skip to content
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

Merged
merged 9 commits into from
Jan 13, 2025

Conversation

krzysz00
Copy link
Contributor

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).

@krzysz00 krzysz00 force-pushed the index-narrowing branch 3 times, most recently from be116ef to ffa5fc4 Compare December 13, 2024 20:21
@krzysz00 krzysz00 marked this pull request as ready for review December 17, 2024 17:28
@krzysz00 krzysz00 force-pushed the index-narrowing branch 2 times, most recently from 01736ba to a367857 Compare January 6, 2025 21:47
Copy link
Contributor

@MaheshRavishankar MaheshRavishankar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@krzysz00 krzysz00 merged commit 2452b22 into iree-org:main Jan 13, 2025
37 checks passed
@Groverkss
Copy link
Contributor

This pass goes into an infinite loop sometimes

Repro: https://gist.github.com/Groverkss/33313b03fd6cb600553ef511f9e7c6a5

iree-opt --iree-util-optimize-int-arithmetic='narrow-to-i32=true'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants