[PATCH] Disable loop unrolling in loop vectorization pass when VF is 1 on x86

Wei Mi wmi at google.com
Tue May 5 22:36:58 PDT 2015


Hi hfinkel,

The patch is to fix the problem described in https://llvm.org/bugs/show_bug.cgi?id=23217

Loop unrolling in loop vectorization pass has two kinds of benefits: 1. For loop which needs to be both vectorized and unrolled, the unrolling integrated with loop vectorization pass can generate less prologue/epilogue code. 2. unrolling in loop vectorization generates memory boundary check for unrolled loop version, which is useful for better scheduling on some architectures.

However, for x86, its performance is not very sensitive to compile time scheduling. So unrolling in loop vectorization when VF==1 will introduce extra cost of overflow check, memory boundary check and sometimes extra prologue/epilogue code when regular unroller will unroll the loop another time. These are harmful for performance on x86.   

The patch disabled unrolling in loop vectorization pass when VF==1 on x86 architecture, by setting MaxInterleaveFactor to 1.

Performance neutral for spec2000. Google internal benchmarks: detection improved by 5% on sandybridge and 9% on westmere, saw improved by 1.5% on both platforms.

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D9515

Files:
  include/llvm/Analysis/TargetTransformInfo.h
  include/llvm/Analysis/TargetTransformInfoImpl.h
  include/llvm/CodeGen/BasicTTIImpl.h
  lib/Analysis/TargetTransformInfo.cpp
  lib/Target/AArch64/AArch64TargetTransformInfo.cpp
  lib/Target/AArch64/AArch64TargetTransformInfo.h
  lib/Target/ARM/ARMTargetTransformInfo.h
  lib/Target/PowerPC/PPCTargetTransformInfo.cpp
  lib/Target/PowerPC/PPCTargetTransformInfo.h
  lib/Target/R600/AMDGPUTargetTransformInfo.cpp
  lib/Target/R600/AMDGPUTargetTransformInfo.h
  lib/Target/X86/X86TargetTransformInfo.cpp
  lib/Target/X86/X86TargetTransformInfo.h
  lib/Transforms/Vectorize/LoopVectorize.cpp
  test/Transforms/LoopVectorize/X86/unroll-small-loops.ll
  test/Transforms/LoopVectorize/unroll.ll

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9515.25008.patch
Type: text/x-patch
Size: 10282 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150506/3f4ea2e4/attachment.bin>


More information about the llvm-commits mailing list