llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

EltsFromConsecutiveLoads does not preserve chain successor dependencies from the original loads.

Open llvmbot opened this issue 15 years ago • 7 comments

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

llvmbot avatar Jun 09 '11 20:06 llvmbot

Yes, fixed by https://reviews.llvm.org/rL314988.

arpilipe avatar Oct 06 '17 13:10 arpilipe

I think https://reviews.llvm.org/D38547 fixed this?

RKSimon avatar Oct 06 '17 09:10 RKSimon

Marking this as a non-release blocker. Though it is quite disturbing...

llvmbot avatar May 01 '12 23:05 llvmbot

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

llvmbot avatar Jun 10 '11 16:06 llvmbot

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.)

efriedma-quic avatar Jun 10 '11 08:06 efriedma-quic