[PATCH] D67363: [BreakFalseDeps] ignore function with minsize attribute
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 9 12:03:30 PDT 2019
spatel created this revision.
spatel added reviewers: craig.topper, RKSimon.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: LLVM.
This came up in the x86-specific:
https://bugs.llvm.org/show_bug.cgi?id=43239
...but it seems like a general problem for the BreakFalseDeps pass. Dependencies are always broken by adding some other instruction, so that should be avoided if the overall goal is to minimize size.
https://reviews.llvm.org/D67363
Files:
llvm/lib/CodeGen/BreakFalseDeps.cpp
llvm/test/CodeGen/X86/sqrt-partial.ll
llvm/test/CodeGen/X86/stack-folding-fp-sse42.ll
Index: llvm/test/CodeGen/X86/stack-folding-fp-sse42.ll
===================================================================
--- llvm/test/CodeGen/X86/stack-folding-fp-sse42.ll
+++ llvm/test/CodeGen/X86/stack-folding-fp-sse42.ll
@@ -583,7 +583,6 @@
; CHECK-NEXT: #APP
; CHECK-NEXT: nop
; CHECK-NEXT: #NO_APP
-; CHECK-NEXT: xorps %xmm0, %xmm0
; CHECK-NEXT: cvtsd2ss {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 8-byte Folded Reload
; CHECK-NEXT: retq
%1 = tail call <2 x i64> asm sideeffect "nop", "=x,~{xmm1},~{xmm2},~{xmm3},~{xmm4},~{xmm5},~{xmm6},~{xmm7},~{xmm8},~{xmm9},~{xmm10},~{xmm11},~{xmm12},~{xmm13},~{xmm14},~{xmm15},~{flags}"()
@@ -975,7 +974,6 @@
; CHECK-NEXT: #APP
; CHECK-NEXT: nop
; CHECK-NEXT: #NO_APP
-; CHECK-NEXT: xorps %xmm0, %xmm0
; CHECK-NEXT: cvtss2sd {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 4-byte Folded Reload
; CHECK-NEXT: retq
%1 = tail call <2 x i64> asm sideeffect "nop", "=x,~{xmm1},~{xmm2},~{xmm3},~{xmm4},~{xmm5},~{xmm6},~{xmm7},~{xmm8},~{xmm9},~{xmm10},~{xmm11},~{xmm12},~{xmm13},~{xmm14},~{xmm15},~{flags}"()
@@ -2012,7 +2010,6 @@
; CHECK-NEXT: #APP
; CHECK-NEXT: nop
; CHECK-NEXT: #NO_APP
-; CHECK-NEXT: xorps %xmm0, %xmm0
; CHECK-NEXT: roundss $9, {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 4-byte Folded Reload
; CHECK-NEXT: retq
%1 = tail call <2 x i64> asm sideeffect "nop", "=x,~{xmm1},~{xmm2},~{xmm3},~{xmm4},~{xmm5},~{xmm6},~{xmm7},~{xmm8},~{xmm9},~{xmm10},~{xmm11},~{xmm12},~{xmm13},~{xmm14},~{xmm15},~{flags}"()
@@ -2181,7 +2178,6 @@
; CHECK-NEXT: #APP
; CHECK-NEXT: nop
; CHECK-NEXT: #NO_APP
-; CHECK-NEXT: xorps %xmm0, %xmm0
; CHECK-NEXT: sqrtss {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 4-byte Folded Reload
; CHECK-NEXT: retq
%1 = tail call <2 x i64> asm sideeffect "nop", "=x,~{xmm1},~{xmm2},~{xmm3},~{xmm4},~{xmm5},~{xmm6},~{xmm7},~{xmm8},~{xmm9},~{xmm10},~{xmm11},~{xmm12},~{xmm13},~{xmm14},~{xmm15},~{flags}"()
Index: llvm/test/CodeGen/X86/sqrt-partial.ll
===================================================================
--- llvm/test/CodeGen/X86/sqrt-partial.ll
+++ llvm/test/CodeGen/X86/sqrt-partial.ll
@@ -44,7 +44,6 @@
; CHECK-NEXT: mulsd %xmm0, %xmm0
; CHECK-NEXT: mulsd %xmm1, %xmm1
; CHECK-NEXT: addsd %xmm0, %xmm1
-; CHECK-NEXT: xorps %xmm0, %xmm0
; CHECK-NEXT: sqrtsd %xmm1, %xmm0
; CHECK-NEXT: retq
%t3 = fmul fast double %x, %x
Index: llvm/lib/CodeGen/BreakFalseDeps.cpp
===================================================================
--- llvm/lib/CodeGen/BreakFalseDeps.cpp
+++ llvm/lib/CodeGen/BreakFalseDeps.cpp
@@ -9,11 +9,11 @@
/// \file Break False Dependency pass.
///
/// Some instructions have false dependencies which cause unnecessary stalls.
-/// For exmaple, instructions that only write part of a register, and implicitly
+/// For example, instructions that only write part of a register, and implicitly
/// need to read the other parts of the register. This may cause unwanted
/// stalls preventing otherwise unrelated instructions from executing in
/// parallel in an out-of-order CPU.
-/// This pass is aimed at identifying and avoiding these depepndencies when
+/// This pass is aimed at identifying and avoiding these dependencies when
/// possible.
//
//===----------------------------------------------------------------------===//
@@ -252,6 +252,12 @@
bool BreakFalseDeps::runOnMachineFunction(MachineFunction &mf) {
if (skipFunction(mf.getFunction()))
return false;
+
+ // This pass adds instructions to remove dependencies. That opposes the goal
+ // of minimizing size.
+ if (mf.getFunction().hasMinSize())
+ return false;
+
MF = &mf;
TII = MF->getSubtarget().getInstrInfo();
TRI = MF->getSubtarget().getRegisterInfo();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67363.219403.patch
Type: text/x-patch
Size: 3744 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190909/3cc36028/attachment.bin>
More information about the llvm-commits
mailing list