-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Coalescer cannot coalesce A = B .. B = A if 'A' is live out #1237
Comments
assigned to @lattner |
Reduced testcase: int %foo(int %t, int %C) { cond_true: ; preds = %cond_true, %entry bb12: ; preds = %cond_true _foo: |
Actually, I was wrong above, eax isn't dead, it's used by the ret outside the loop. |
This fix for this one case is pretty trivial (I'm testing it now). One question, should we modify it so that LBB1_1: #cond_true Is transformed into: LBB1_1: #cond_true ? -bw |
Fixed. After thinking about it some more, doing a check for the "general" case would be at least O(N^2) |
This is definitely an improvement, but not enough. The generated code now looks like this: _foo: This is clearly better than having two movs, but it would be better to have: _foo: I think that this is a coallescing problem, the PHI live-range isn't getting coallesced with the copy into -Chris |
Ah! Yes. I see what you mean. Okay, I'll delve more deeply into the coalescer. |
No, I'm confused. My suggestion would produce a different result. However, it does seem better to solve |
Fixed. Testcase here: X86/2006-08-21-ExtraMovInst.ll Patches here: -Chris |
Move header files in lib/Lower.
refs llvm#1237 既存のtest/MTをlit対応する(grepで文字列を確認5) See merge request a64fx-swpl/llvm-project!25
Extended Description
llc -fast -march=x86 on this .ll file:
int %foo(int* %a, int %t, int %C) {
entry:
%a = cast int* %a to uint ; [#uses=1]
br label %cond_true
cond_true: ; preds = %cond_true, %entry
%iv. = phi uint [ %a, %entry ], [ %iv..inc, %cond_true ] ; [#uses=2]
%t_addr.0.0 = phi int [ %t, %entry ], [ %tmp7, %cond_true ] ; [#uses=2]
%iv. = cast uint %iv. to int* ; <int*> [#uses=1]
%tmp3 = load int* %iv. ; [#uses=1]
%tmp7 = add int %t_addr.0.0, %tmp3 ; [#uses=1]
%tmp = setgt int %C, 39 ; [#uses=1]
%iv..inc = add uint %iv., 4 ; [#uses=1]
br bool %tmp, label %bb12, label %cond_true
bb12: ; preds = %cond_true
ret int %t_addr.0.0
}
produces:
_foo:
subl $4, %esp
movl %esi, (%esp)
movl 8(%esp), %ecx
movl 16(%esp), %edx
movl 12(%esp), %esi
LBB1_1: #cond_true
*** movl %esi, %eax
*** movl %eax, %esi
addl (%ecx), %esi
addl $4, %ecx
cmpl $40, %edx
jl LBB1_1 #cond_true
LBB1_2: #bb12
movl (%esp), %esi
addl $4, %esp
ret
It is safe to say that that is not the fastest way to copy esi into esi. Note that eax is dead.
-Chris
The text was updated successfully, but these errors were encountered: