diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-05-22 20:22:47 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-05-22 20:22:47 +0000 |
commit | 2959ff4a88da384d4620bf71110244a261ae971a (patch) | |
tree | f9e9d0202b0ec84320feac0044e763d5a79d8325 | |
parent | 3b0bde2c2ce023b5b9e750875ad5099aa4af59d9 (diff) | |
download | bcm5719-llvm-2959ff4a88da384d4620bf71110244a261ae971a.tar.gz bcm5719-llvm-2959ff4a88da384d4620bf71110244a261ae971a.zip |
[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
llvm-svn: 270378
-rw-r--r-- | llvm/lib/Target/X86/X86VZeroUpper.cpp | 6 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/avx-intrinsics-fast-isel.ll | 4 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/avx-intrinsics-x86.ll | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/Target/X86/X86VZeroUpper.cpp b/llvm/lib/Target/X86/X86VZeroUpper.cpp index 2d053a65a44..fc39c0c80eb 100644 --- a/llvm/lib/Target/X86/X86VZeroUpper.cpp +++ b/llvm/lib/Target/X86/X86VZeroUpper.cpp @@ -192,6 +192,12 @@ void VZeroUpperInserter::processBasicBlock(MachineBasicBlock &MBB) { 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. diff --git a/llvm/test/CodeGen/X86/avx-intrinsics-fast-isel.ll b/llvm/test/CodeGen/X86/avx-intrinsics-fast-isel.ll index 18792fb78d3..2c29e009cfb 100644 --- a/llvm/test/CodeGen/X86/avx-intrinsics-fast-isel.ll +++ b/llvm/test/CodeGen/X86/avx-intrinsics-fast-isel.ll @@ -3736,13 +3736,11 @@ define void @test_mm256_zeroall() nounwind { ; 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() nounwind { ; 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 diff --git a/llvm/test/CodeGen/X86/avx-intrinsics-x86.ll b/llvm/test/CodeGen/X86/avx-intrinsics-x86.ll index c21784dad70..73064eaaebc 100644 --- a/llvm/test/CodeGen/X86/avx-intrinsics-x86.ll +++ b/llvm/test/CodeGen/X86/avx-intrinsics-x86.ll @@ -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: |