[PATCH] D20477: [x86, AVX] don't add a vzeroupper if that's what the code is already doing (PR27823)

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri May 20 10:42:33 PDT 2016


spatel created this revision.
spatel added reviewers: RKSimon, aaboud, ygao.
spatel added a subscriber: llvm-commits.
Herald added a subscriber: mcrosier.

This isn't the complete fix, but it handles the trivial examples of duplicate vzero* ops in PR27823:
https://llvm.org/bugs/show_bug.cgi?id=27823
...and amusingly, the bogus cases already exist as regression tests, so let's take this baby step.  

We'll need to do more in the general case where there's legitimate AVX usage in the function + there's already a vzero in the code.

http://reviews.llvm.org/D20477

Files:
  lib/Target/X86/X86VZeroUpper.cpp
  test/CodeGen/X86/avx-intrinsics-x86.ll

Index: test/CodeGen/X86/avx-intrinsics-x86.ll
===================================================================
--- test/CodeGen/X86/avx-intrinsics-x86.ll
+++ test/CodeGen/X86/avx-intrinsics-x86.ll
@@ -4755,7 +4755,6 @@
 ; AVX-LABEL: test_x86_avx_vzeroall:
 ; AVX:       ## BB#0:
 ; AVX-NEXT:    vzeroall
-; AVX-NEXT:    vzeroupper
 ; AVX-NEXT:    retl
 ;
 ; AVX512VL-LABEL: test_x86_avx_vzeroall:
@@ -4772,7 +4771,6 @@
 ; AVX-LABEL: test_x86_avx_vzeroupper:
 ; AVX:       ## BB#0:
 ; AVX-NEXT:    vzeroupper
-; AVX-NEXT:    vzeroupper
 ; AVX-NEXT:    retl
 ;
 ; AVX512VL-LABEL: test_x86_avx_vzeroupper:
Index: lib/Target/X86/X86VZeroUpper.cpp
===================================================================
--- lib/Target/X86/X86VZeroUpper.cpp
+++ lib/Target/X86/X86VZeroUpper.cpp
@@ -128,6 +128,11 @@
 }
 
 static bool hasYmmReg(MachineInstr *MI) {
+  // For the purpose of inserting VZERO* instructions, ignore existing VZERO*
+  // instructions.
+  if (MI->getOpcode() == X86::VZEROALL || MI->getOpcode() == X86::VZEROUPPER)
+    return false;
+
   for (const MachineOperand &MO : MI->operands()) {
     if (MI->isCall() && MO.isRegMask() && !clobbersAllYmmRegs(MO))
       return true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20477.57953.patch
Type: text/x-patch
Size: 1197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160520/6d32c7f5/attachment.bin>


More information about the llvm-commits mailing list