diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2015-01-14 20:19:29 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2015-01-14 20:19:29 +0000 |
| commit | e3288147f0869512b7bc877a6c33b684b9ffa615 (patch) | |
| tree | 5a163bd11ae623668bee847fd0eadd9eb057931e /llvm/test | |
| parent | 082cfc05f1509da7aa87fd1e30e279755b4477d8 (diff) | |
| download | bcm5719-llvm-e3288147f0869512b7bc877a6c33b684b9ffa615.tar.gz bcm5719-llvm-e3288147f0869512b7bc877a6c33b684b9ffa615.zip | |
[MBP] Add flags to disable the BadCFGConflict check in MachineBlockPlacement.
Some benchmarks have shown that this could lead to a potential
performance benefit, and so adding some flags to try to help measure the
difference.
A possible explanation. In diamond-shaped CFGs (A followed by either
B or C both followed by D), putting B and C both in between A and
D leads to the code being less dense than it could be. Always either
B or C have to be skipped increasing the chance of cache misses etc.
Moving either B or C to after D might be beneficial on average.
In the long run, but we should probably do a better job of analyzing the
basic block and branch probabilities to move the correct one of B or
C to after D. But even if we don't use this in the long run, it is
a good baseline for benchmarking.
Original patch authored by Daniel Jasper with test tweaks and a second
flag added by me.
Differential Revision: http://reviews.llvm.org/D6969
llvm-svn: 226034
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/CodeGen/X86/code_placement_bad_cfg_check.ll | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/code_placement_bad_cfg_check.ll b/llvm/test/CodeGen/X86/code_placement_bad_cfg_check.ll new file mode 100644 index 00000000000..a5f9e8aab1b --- /dev/null +++ b/llvm/test/CodeGen/X86/code_placement_bad_cfg_check.ll @@ -0,0 +1,112 @@ +; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux < %s | FileCheck %s -check-prefix=CHECK-BAD-CFG +; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux -no-bad-cfg-conflict-check < %s | FileCheck %s -check-prefix=CHECK-NO-BAD-CFG +; RUN: llc -mcpu=corei7 -mtriple=x86_64-linux -only-hot-bad-cfg-conflict-check < %s | FileCheck %s -check-prefix=CHECK-HOT-BAD-CFG + +define void @foo(i32 %t) { +; Test that we lift the call to 'c' up to immediately follow the call to 'b' +; when we disable the cfg conflict check. +; +; CHECK-BAD-CFG-LABEL: foo: +; CHECK-BAD-CFG: callq b +; CHECK-BAD-CFG: callq a +; CHECK-BAD-CFG: callq c +; +; CHECK-NO-BAD-CFG-LABEL: foo: +; CHECK-NO-BAD-CFG: callq b +; CHECK-NO-BAD-CFG: callq c +; CHECK-NO-BAD-CFG: callq a +; +; CHECK-HOT-BAD-CFG-LABEL: foo: +; CHECK-HOT-BAD-CFG: callq b +; CHECK-HOT-BAD-CFG: callq c +; CHECK-HOT-BAD-CFG: callq a + +entry: + %cmp = icmp eq i32 %t, 0 + br i1 %cmp, label %if.then, label %if.else + +if.then: + call void @a() + br label %if.end + +if.else: + call void @b() + br label %if.end + +if.end: + call void @c() + ret void +} + +define void @bar(i32 %t1, i32 %t2, i32 %t3) { +; Test that we lift the call to 'c' up to immediately follow the call to 'b' +; when we disable the cfg conflict check. +; +; CHECK-BAD-CFG-LABEL: bar: +; CHECK-BAD-CFG: callq a +; CHECK-BAD-CFG: callq c +; CHECK-BAD-CFG: callq d +; CHECK-BAD-CFG: callq f +; CHECK-BAD-CFG: callq b +; CHECK-BAD-CFG: callq e +; CHECK-BAD-CFG: callq g +; +; CHECK-NO-BAD-CFG-LABEL: bar: +; CHECK-NO-BAD-CFG: callq a +; CHECK-NO-BAD-CFG: callq c +; CHECK-NO-BAD-CFG: callq g +; CHECK-NO-BAD-CFG: callq d +; CHECK-NO-BAD-CFG: callq f +; CHECK-NO-BAD-CFG: callq b +; CHECK-NO-BAD-CFG: callq e +; +; CHECK-HOT-BAD-CFG-LABEL: bar: +; CHECK-HOT-BAD-CFG: callq a +; CHECK-HOT-BAD-CFG: callq c +; CHECK-HOT-BAD-CFG: callq d +; CHECK-HOT-BAD-CFG: callq f +; CHECK-HOT-BAD-CFG: callq g +; CHECK-HOT-BAD-CFG: callq b +; CHECK-HOT-BAD-CFG: callq e + +entry: + br i1 undef, label %if1.then, label %if1.else + +if1.then: + call void @a() + %cmp2 = icmp eq i32 %t2, 0 + br i1 %cmp2, label %if2.then, label %if2.else + +if2.then: + call void @b() + br label %if.end + +if2.else: + call void @c() + br label %if.end + +if1.else: + call void @d() + %cmp3 = icmp eq i32 %t3, 0 + br i1 %cmp3, label %if3.then, label %if3.else + +if3.then: + call void @e() + br label %if.end + +if3.else: + call void @f() + br label %if.end + +if.end: + call void @g() + ret void +} + +declare void @a() +declare void @b() +declare void @c() +declare void @d() +declare void @e() +declare void @f() +declare void @g() |

