-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Inverted movemasks result in redundant logic #89533
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
Labels
Comments
define i64 @PR89533(<64 x i8> %a0) {
%cmp = icmp ne <64 x i8> %a0, <i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95, i8 95>
%mask = bitcast <64 x i1> %cmp to i64
%tz = tail call i64 @llvm.cttz.i64(i64 %mask, i1 false)
ret i64 %tz
}
We might be able to handle this in foldLogicTreeOfShifts |
Or even simpler: define i64 @notpair(i32 %a0, i32 %a1) {
%n0 = xor i32 %a0, -1
%n1 = xor i32 %a1, -1
%x0 = zext i32 %n0 to i64
%x1 = zext i32 %n1 to i64
%hi = shl i64 %x1, 32
%r = or i64 %hi, %x0
ret i64 %r
}
define i64 @not(i32 %a0, i32 %a1) {
%x0 = zext i32 %a0 to i64
%x1 = zext i32 %a1 to i64
%hi = shl i64 %x1, 32
%r = or i64 %hi, %x0
%n = xor i64 %r, -1
ret i64 %n
} notpair: # @notpair
notl %edi
notl %esi
shlq $32, %rsi
leaq (%rsi,%rdi), %rax
retq
not: # @not
movl %edi, %eax
shlq $32, %rsi
orq %rsi, %rax
notq %rax
retq |
RKSimon
added a commit
to RKSimon/llvm-project
that referenced
this issue
Apr 25, 2024
…d_pair(x,y)) style patterns (Sorry, not an actual build_pair node just a similar pattern). For cases where we're concatenating 2 integers into a double width integer, see if both integer sources are NOT patterns. We could take this further and handle all logic ops with a constant operands, but I just wanted to handle the case reported on llvm#89533 initially. Fixes llvm#89533
RKSimon
added a commit
to RKSimon/llvm-project
that referenced
this issue
Apr 25, 2024
…d_pair(x,y)) style patterns (Sorry, not an actual build_pair node just a similar pattern). For cases where we're concatenating 2 integers into a double width integer, see if both integer sources are NOT patterns. We could take this further and handle all logic ops with a constant operands, but I just wanted to handle the case reported on llvm#89533 initially. Fixes llvm#89533
RKSimon
added a commit
to RKSimon/llvm-project
that referenced
this issue
Apr 26, 2024
…d_pair(x,y)) style patterns (Sorry, not an actual build_pair node just a similar pattern). For cases where we're concatenating 2 integers into a double width integer, see if both integer sources are NOT patterns. We could take this further and handle all logic ops with a constant operands, but I just wanted to handle the case reported on llvm#89533 initially. Fixes llvm#89533
RKSimon
added a commit
that referenced
this issue
Apr 26, 2024
RKSimon
added a commit
to RKSimon/llvm-project
that referenced
this issue
Apr 26, 2024
…d_pair(x,y)) style patterns (Sorry, not an actual build_pair node just a similar pattern). For cases where we're concatenating 2 integers into a double width integer, see if both integer sources are NOT patterns. We could take this further and handle all logic ops with a constant operands, but I just wanted to handle the case reported on llvm#89533 initially. Fixes llvm#89533
RKSimon
added a commit
to RKSimon/llvm-project
that referenced
this issue
Apr 26, 2024
…d_pair(x,y)) style patterns (Sorry, not an actual build_pair node just a similar pattern). For cases where we're concatenating 2 integers into a double width integer, see if both integer sources are NOT patterns. We could take this further and handle all logic ops with a constant operands, but I just wanted to handle the case reported on llvm#89533 initially. Fixes llvm#89533
RKSimon
added a commit
that referenced
this issue
Apr 26, 2024
…d_pair(x,y)) style patterns (#90050) (Sorry, not an actual build_pair node just a similar pattern). For cases where we're concatenating 2 integers into a double width integer, see if both integer sources are NOT patterns. We could take this further and handle all logic ops with a constant operands, but I just wanted to handle the case reported on #89533 initially. Fixes #89533
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wrote this
tokenize
function: (https://zig.godbolt.org/z/oYosTb1zK)Next I made the following change:
Unfortunately, this results in different emit.
First version (Zen 4):
Second version (Zen 4):
First version (Zen 3):
Second version (Zen 3):
https://zig.godbolt.org/z/oYosTb1zK
The text was updated successfully, but these errors were encountered: