-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
sext(square nsw) produces unnecessary zext on riscv64/mips64/loongarch64 #62587
Comments
Reproduces on post-17 trunk with |
@llvm/issue-subscribers-backend-risc-v
Minimal C reproducer(s):
int a(int x) { return x*x; }
long b(int x) { return x*x; } Expected output (on riscv64, generated with a: # @<!-- -->a
mulw a0, a0, a0
ret What is actually generated: a: # @<!-- -->a
mulw a0, a0, a0
slli a0, a0, 32
srli a0, a0, 32
ret compiler explorer link: https://godbolt.org/z/Yq898xoT1. Clang 14 produces the optimal code for |
Partially fixed by #65984. I am working on the middle-end part. |
@topperc @nikic @goldsteinn @preames There are some benefits from
See also: |
See https://reviews.llvm.org/D156444 for the correct solution to this problem. |
It should be addressed by #67982 and follow-up PRs. |
It has been addressed on the RISC-V backend. |
@llvm/issue-subscribers-backend-mips Author: sorear (sorear)
Minimal C reproducer(s):
int a(int x) { return x*x; }
long b(int x) { return x*x; } Expected output (on riscv64, generated with a: # @<!-- -->a
mulw a0, a0, a0
ret What is actually generated: a: # @<!-- -->a
mulw a0, a0, a0
slli a0, a0, 32
srli a0, a0, 32
ret compiler explorer link: https://godbolt.org/z/Yq898xoT1. Clang 14 produces the optimal code for |
@llvm/issue-subscribers-backend-risc-v Author: sorear (sorear)
Minimal C reproducer(s):
int a(int x) { return x*x; }
long b(int x) { return x*x; } Expected output (on riscv64, generated with a: # @<!-- -->a
mulw a0, a0, a0
ret What is actually generated: a: # @<!-- -->a
mulw a0, a0, a0
slli a0, a0, 32
srli a0, a0, 32
ret compiler explorer link: https://godbolt.org/z/Yq898xoT1. Clang 14 produces the optimal code for |
@dtcxzyw IIUC RISC-V backend was affected by this, so we should keep the corresponding label, even though it's been addressed. |
Minimal C reproducer(s):
Expected output (on riscv64, generated with
-fwrapv
):What is actually generated:
compiler explorer link: https://godbolt.org/z/Yq898xoT1. Clang 14 produces the optimal code for
a
but not forb
.The text was updated successfully, but these errors were encountered: