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

failed to fold shift amount offset into shift of a constant, part 2 #55016

Closed
rotateright opened this issue Apr 21, 2022 · 1 comment
Closed
Labels
good first issue https://github.com/llvm/llvm-project/contribute llvm:instcombine missed-optimization

Comments

@rotateright
Copy link
Contributor

rotateright commented Apr 21, 2022

Forking this off from #54890 - that handled a shift-left variant, but there's a similar shift-right fold that could be added:
https://alive2.llvm.org/ce/z/qzh4oK

define i32 @src(i32 %x, i32 %c, i32 %addc) {
  %a = add i32 %x, -1
  %r = ashr exact i32 -2, %a
  ret i32 %r
}

define i32 @tgt(i32 %x, i32 %c, i32 %addc) {
  %r = ashr i32 -4, %x
  ret i32 %r
}

This should be generalized for other constant values, and it should also work in the more common case of a positive shift constant with "lshr".

@rotateright rotateright added good first issue https://github.com/llvm/llvm-project/contribute llvm:instcombine missed-optimization and removed new issue labels Apr 21, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Apr 21, 2022

@llvm/issue-subscribers-good-first-issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue https://github.com/llvm/llvm-project/contribute llvm:instcombine missed-optimization
Projects
None yet
Development

No branches or pull requests

2 participants