[llvm] r270378 - [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
Sun May 22 13:22:49 PDT 2016
Author: spatel
Date: Sun May 22 15:22:47 2016
New Revision: 270378
URL: http://llvm.org/viewvc/llvm-project?rev=270378&view=rev
Log:
[x86, AVX] don't add a vzeroupper if that's what the code is already doing (PR27823)
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.
Differential Revision: http://reviews.llvm.org/D20477
Modified:
llvm/trunk/lib/Target/X86/X86VZeroUpper.cpp
llvm/trunk/test/CodeGen/X86/avx-intrinsics-fast-isel.ll
llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86.ll
Modified: llvm/trunk/lib/Target/X86/X86VZeroUpper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86VZeroUpper.cpp?rev=270378&r1=270377&r2=270378&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86VZeroUpper.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86VZeroUpper.cpp Sun May 22 15:22:47 2016
@@ -192,6 +192,12 @@ void VZeroUpperInserter::processBasicBlo
if ((!IsControlFlow || IsReturnFromX86INTR) && CurState == EXITS_DIRTY)
continue;
+ // Ignore existing VZERO* instructions.
+ // FIXME: The existence of these instructions should be used to modify the
+ // current state and/or used when deciding whether we need to create a VZU.
+ if (MI->getOpcode() == X86::VZEROALL || MI->getOpcode() == X86::VZEROUPPER)
+ continue;
+
if (hasYmmReg(MI)) {
// We found a ymm-using instruction; this could be an AVX instruction,
// or it could be control flow.
Modified: llvm/trunk/test/CodeGen/X86/avx-intrinsics-fast-isel.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avx-intrinsics-fast-isel.ll?rev=270378&r1=270377&r2=270378&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/avx-intrinsics-fast-isel.ll (original)
+++ llvm/trunk/test/CodeGen/X86/avx-intrinsics-fast-isel.ll Sun May 22 15:22:47 2016
@@ -3736,13 +3736,11 @@ define void @test_mm256_zeroall() nounwi
; X32-LABEL: test_mm256_zeroall:
; X32: # BB#0:
; X32-NEXT: vzeroall
-; X32-NEXT: vzeroupper
; X32-NEXT: retl
;
; X64-LABEL: test_mm256_zeroall:
; X64: # BB#0:
; X64-NEXT: vzeroall
-; X64-NEXT: vzeroupper
; X64-NEXT: retq
call void @llvm.x86.avx.vzeroall()
ret void
@@ -3753,13 +3751,11 @@ define void @test_mm256_zeroupper() noun
; X32-LABEL: test_mm256_zeroupper:
; X32: # BB#0:
; X32-NEXT: vzeroupper
-; X32-NEXT: vzeroupper
; X32-NEXT: retl
;
; X64-LABEL: test_mm256_zeroupper:
; X64: # BB#0:
; X64-NEXT: vzeroupper
-; X64-NEXT: vzeroupper
; X64-NEXT: retq
call void @llvm.x86.avx.vzeroupper()
ret void
Modified: llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86.ll?rev=270378&r1=270377&r2=270378&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86.ll (original)
+++ llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86.ll Sun May 22 15:22:47 2016
@@ -4755,7 +4755,6 @@ define void @test_x86_avx_vzeroall() {
; 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 @@ define void @test_x86_avx_vzeroupper() {
; AVX-LABEL: test_x86_avx_vzeroupper:
; AVX: ## BB#0:
; AVX-NEXT: vzeroupper
-; AVX-NEXT: vzeroupper
; AVX-NEXT: retl
;
; AVX512VL-LABEL: test_x86_avx_vzeroupper:
More information about the llvm-commits
mailing list