-
Notifications
You must be signed in to change notification settings - Fork 13.5k
i32 load + zext is merged into 64-bit load for __ptr32 on amd64 #66873
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
@llvm/issue-subscribers-backend-x86
## Reproduction
https://godbolt.org/z/PGK3PEf64 __attribute((noinline))
uint64_t LoadAsLong(uint32_t* __ptr32 foo) {
return static_cast<uint64_t>(*foo);
} I expect that the If do not use InvestigationClang produces the following assembly for the movslq %edi, %rax
movq (%rax), %rax
retq the assembly loads 64 bit value but had to load 32 bits. As far as I see llvm IR for the function is correct before isel: define dso_local noundef i64 @<!-- -->LoadAsLong(unsigned int ptr32_sptr*)(ptr addrspace(270) nocapture noundef readonly %foo) local_unnamed_addr {
entry:
%0 = load i32, ptr addrspace(270) %foo, align 4
%conv = zext i32 %0 to i64
ret i64 %conv
} but after isel:
there is |
Type extension and truncation is missed when combining loads and stores for ptr32 and ptr64. Closes llvm#66873
Reproduction
https://godbolt.org/z/PGK3PEf64
I expect that the
LoadAsLong
will return42
for the test case in the godbolt listing.But it does not.
If do not use
__ptr32
, then theLoadAsLong
returns 42Investigation
Clang produces the following assembly for the
LoadAsLong
function:the assembly loads 64 bit value but had to load 32 bits.
As far as I see llvm IR for the function is correct before isel:
but after isel:
there is
load (s64) from %ir.foo, align 4, addrspace 270
The text was updated successfully, but these errors were encountered: