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

[InstSimplify] rotating all-ones is still all-ones #50917

Closed
rotateright opened this issue Aug 22, 2021 · 4 comments
Closed

[InstSimplify] rotating all-ones is still all-ones #50917

rotateright opened this issue Aug 22, 2021 · 4 comments
Labels
bugzilla Issues migrated from bugzilla

Comments

@rotateright
Copy link
Contributor

Bugzilla Link 51575
Resolution FIXED
Resolved on Aug 24, 2021 12:54
Version trunk
OS All
CC @RKSimon
Fixed by commit(s) d41e308 dcf659e 204038d

Extended Description

I'm not sure if there's overlap between this and related rotate bugs, but filing it so we have a reference:

define i32 @​src(i32 %shamt) {
%r = lshr i32 -1, %shamt
%s = sub i32 32, %shamt
%l = shl i32 -1, %s
%o = or i32 %r, %l
ret i32 %o
}

define i32 @​tgt(i32 %shamt) {
ret i32 -1
}

https://alive2.llvm.org/ce/z/gDke_c

We do handle the sibling rotate-of-zero (probably via known bits or simpler folds since all bits are the same in that case).

@rotateright
Copy link
Contributor Author

Also missing the easier pattern with a funnel shift intrinsic:

define i64 @​src(i64 %x) {
%r = tail call i64 @​llvm.fshl.i64(i64 -1, i64 -1, i64 %x)
ret i64 %r
}

define i64 @​tgt(i64 %x) {
ret i64 -1
}

https://alive2.llvm.org/ce/z/GpkFCt

@rotateright
Copy link
Contributor Author

And we miss the intrinsic case even with zero:
https://alive2.llvm.org/ce/z/fjKwqv

@rotateright
Copy link
Contributor Author

The intrinsic patterns should be fixed with:
https://reviews.llvm.org/rGd41e308f109e
https://reviews.llvm.org/rGdcf659e8219b

@rotateright
Copy link
Contributor Author

Handle the original, non-intrinsic rotate pattern:
https://reviews.llvm.org/rG204038d52e03

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

1 participant