diff options
author | Dehao Chen <dehao@google.com> | 2016-06-23 20:13:10 +0000 |
---|---|---|
committer | Dehao Chen <dehao@google.com> | 2016-06-23 20:13:10 +0000 |
commit | 934217e9c9d28a9d630c9cbec73885180c9bc32b (patch) | |
tree | 51d136754d164d08653abb5d74490b3eb8f0b857 /test | |
parent | 0b79e05d0ec7b3e235506db9837bb6f74c7cd829 (diff) |
Invoke simplifycfg and sroa before instcombine.
Summary: InstCombine needs to be performed after simplifycfg and sroa, otherwise it may make bad optimization decisions.
Reviewers: davidxl, wmi, dnovillo
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D21568
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273606 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGen/pgo-sample-preparation.c | 16 | ||||
-rw-r--r-- | test/CodeGen/pgo-sample.c | 3 |
2 files changed, 19 insertions, 0 deletions
diff --git a/test/CodeGen/pgo-sample-preparation.c b/test/CodeGen/pgo-sample-preparation.c new file mode 100644 index 0000000000..c0a3cb4bc5 --- /dev/null +++ b/test/CodeGen/pgo-sample-preparation.c @@ -0,0 +1,16 @@ +// Test if PGO sample use preparation passes are executed correctly. +// +// Ensure that instcombine is executed after simplifycfg and sroa so that +// "a < 255" will not be converted to a * 256 < 255 * 256. +// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -emit-llvm -o - 2>&1 | FileCheck %s + +void bar(int); +void foo(int x, int y, int z) { + int m; + for (m = 0; m < x ; m++) { + int a = (((y >> 8) & 0xff) * z) / 256; + bar(a < 255 ? a : 255); + } +} + +// CHECK-NOT: icmp slt i32 %mul, 65280 diff --git a/test/CodeGen/pgo-sample.c b/test/CodeGen/pgo-sample.c index e7d2fa61aa..c955edfab7 100644 --- a/test/CodeGen/pgo-sample.c +++ b/test/CodeGen/pgo-sample.c @@ -2,5 +2,8 @@ // // Ensure Pass PGOInstrumentationGenPass is invoked. // RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s +// CHECK: Simplify the CFG +// CHECK: SROA +// CHECK: Combine redundant instructions // CHECK: Remove unused exception handling info // CHECK: Sample profile pass |