-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
powerpc64le tail recursion miscompilation #62294
Comments
@llvm/issue-subscribers-backend-powerpc |
I checked the emitted assembly:
The relevant part appears to be this:
so it loads the values into r3 and r4 and does a comparison; then it performs a swap (r5 = r4; r4 = r3; r3 = r5) and jumps to label based on result of comparison; however, it does not compare again, so it's just bound to keep swapping the register values forever, if i understand this correctly the label should probably be before the compare? also, this only happens at -O2 and higher opt levels |
code emitted from gcc:
indeed places the compare after the label |
This is a bug in https://reviews.llvm.org/D38236 ( |
generated code with patch:
i guess that looks fine? the only difference from gcc is that the temporary save part of the swap is done before the cmp, but that should not matter as far as i can tell, otherwise it is essentially identical |
The following code enters infinite loop:
Confirmed on
ppc64le
with Clang 12 and 15 by me and Git by @MaskRay. Confirmed it does not happen on at leastx86_64
,aarch64
andriscv64
. Appears to be unrelated to anything other than the architecture, so it seems to be a codegen backend bug.The text was updated successfully, but these errors were encountered: