EltsFromConsecutiveLoads does not preserve chain successor dependencies from the original loads.
| Bugzilla Link | 10114 |
| Resolution | FIXED |
| Resolved on | Oct 06, 2017 06:20 |
| Version | trunk |
| OS | All |
| Reporter | LLVM Bugzilla Contributor |
| CC | @arpilipe,@b-sumner,@efriedma-quic,@filcab,@RKSimon,@sunfishcode,@rotateright |
Extended Description
The EltsFromConsecutiveLoads in X86ISelLowering.cpp replaces several load instructions with a single instruction. But if the replaced loads are before a a call the new load may be inserted after the call, because the dependencies are not preserved.
For example:
chain
/ \
/ \
V V
load addr load addr+4 | \ / | | \ / | | V V | | token_factor | | | | \ | / \ V / \ call / \ / \ / \ / op1 op2
Will be replaced with:
token_factor
|
|
V
call
chain
|
|
V
vload (not guaranteed to be executed before the call)
/ \
/ \
/ \
op1 op2
Yes, fixed by https://reviews.llvm.org/rL314988.
I think https://reviews.llvm.org/D38547 fixed this?
Marking this as a non-release blocker. Though it is quite disturbing...
Compile the example with these options:
llc -mcpu=i686 -mattr=+sse3 example.bc -o output.s
The bad code is:
calll *(%eax)
movaps 80(%esp), %xmm5 # 16-byte Reload
movaps %xmm5, %xmm0
movaps 64(%esp), %xmm1 # 16-byte Reload
movlhps %xmm1, %xmm0 # xmm0 = xmm0[0],xmm1[0]
shufps $-30, %xmm1, %xmm0 # xmm0 = xmm0[2,0],xmm1[2,3]
movaps %xmm1, %xmm6
movaps 112(%esp), %xmm3 # 16-byte Reload
movaps %xmm3, %xmm2
movaps 96(%esp), %xmm1 # 16-byte Reload
movlhps %xmm1, %xmm2 # xmm2 = xmm2[0],xmm1[0]
shufps $-30, %xmm1, %xmm2 # xmm2 = xmm2[2,0],xmm1[2,3]
movaps %xmm1, %xmm4
movq (%ebx,%edi,8), %xmm1 <- XXX should be before call XXX
subps %xmm2, %xmm1
subps %xmm0, %xmm1
Yes, it does appear to be mishandling the chain. BTW, do you have a testcase? (If you don't, I think I can throw something together, but it would save me some time.)