[PATCH] D20529: [x86, AVX] allow explicit calls to VZERO* to modify state in VZeroUpperInserter pass

David Kreitzer via llvm-commits llvm-commits at lists.llvm.org
Tue May 24 12:55:55 PDT 2016


DavidKreitzer added a subscriber: DavidKreitzer.
DavidKreitzer added a comment.

Your changes LGTM, Sanjay.

For the example you gave, it looks like a problem in coalescing. To eliminate a copy, coalescing extends a VR256 lifetime across the vzeroupper:

  # *** IR Dump After Live Interval Analysis ***:
  # Machine code for function avx_in_sse_out: Properties: <Post SSA, tracking liv\
  eness, HasVRegs>
  Function Live Ins: %YMM0 in %vreg0
  
  0B      BB#0: derived from LLVM BB %0
              Live Ins: %YMM0
  16B             %vreg0<def> = COPY %YMM0; VR256:%vreg0
  32B             %vreg1<def> = COPY %vreg0:sub_xmm; VR128:%vreg1 VR256:%vreg0
  48B             VZEROUPPER
  64B             %XMM0<def> = COPY %vreg1; VR128:%vreg1
  80B             RET 0, %XMM0
  
  # End machine code for function avx_in_sse_out.
  
  # *** IR Dump After Simple Register Coalescing ***:
  # Machine code for function avx_in_sse_out: Properties: <Post SSA, tracking liv\
  eness, HasVRegs>
  Function Live Ins: %YMM0 in %vreg0
  
  0B      BB#0: derived from LLVM BB %0
              Live Ins: %YMM0
  16B             %vreg0<def> = COPY %YMM0; VR256:%vreg0
  48B             VZEROUPPER
  64B             %XMM0<def> = COPY %vreg0:sub_xmm; VR256:%vreg0
  80B             RET 0, %XMM0

Not good! In this case, coalescing would be better off doing this:

  # *** IR Dump After Simple Register Coalescing ***:
  # Machine code for function avx_in_sse_out: Properties: <Post SSA, tracking liv\
  eness, HasVRegs>
  Function Live Ins: %YMM0 in %vreg0
  
  0B      BB#0: derived from LLVM BB %0
              Live Ins: %YMM0
  16B             %vreg1<def> = COPY %YMM0:sub_xmm; VR128:%vreg1
  48B             VZEROUPPER
  64B             %XMM0<def> = COPY %vreg1; VR128:%vreg1
  80B             RET 0, %XMM0


http://reviews.llvm.org/D20529





More information about the llvm-commits mailing list