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
merge truncated stores #46007
Comments
Here's a more involved IR example (aggregate type + extra use of the loaded value), but hopefully no harder to match in SDAG: %struct.TypeSize = type { i16, i16 } @s_typeSizeLookup_1 = external dso_local local_unnamed_addr constant [0 x i32], align 4 define dso_local zeroext i1 @_Z11loadToken_1hP8TypeSize(i8 zeroext %0, %struct.TypeSize* nocapture %1) local_unnamed_addr #0 { |
For reference, this asm is currently: With the change proposed in https://reviews.llvm.org/D86420, we merge to 32-bit store: |
D86420 landed at rG54a5dd485c4d04d142a58c9349ada0c897cbeae6 - followed by D87112 and rG7a06b166b1afb457a7df6ad73a6710b4dde4db68 OK to resolve? |
Thanks for the reminder. There are likely other merge patterns that we still don't get, but I just forgot to mark this example as fixed. |
Extended Description
void i32(long long x, int* p) {
int a = x;
int b = x >> 32;
p[0] = a;
p[1] = b;
}
define void @i32(i64 %0, i32* nocapture %1) {
%3 = trunc i64 %0 to i32
%4 = lshr i64 %0, 32
%5 = trunc i64 %4 to i32
store i32 %3, i32* %1, align 4
%6 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %5, i32* %6, align 4
ret void
}
Compiles to x86-64:
movl %edi, (%rsi)
shrq $32, %rdi
movl %edi, 4(%rsi)
retq
But that could be only:
movq %rdi, (%rsi)
In DAGCombiner, we have MatchStoreCombine(), but it only handles 8-bit; we have mergeConsecutiveStores(), but it doesn't look at trunc patterns.
https://godbolt.org/z/xMPxT9
The text was updated successfully, but these errors were encountered: