summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
authorHiroshi Yamauchi <yamauchi@google.com>2017-07-28 18:35:25 +0000
committerHiroshi Yamauchi <yamauchi@google.com>2017-07-28 18:35:25 +0000
commit1b179bc5ff845e49fe787783ca3c7c8f2949c5bb (patch)
treef136cfefb88d2e208bb37f5b7a0bb4d2bb4513cc /llvm/test/Transforms
parent42698d09b80a152f6cff14ab6bcf0309f67f847e (diff)
downloadbcm5719-llvm-1b179bc5ff845e49fe787783ca3c7c8f2949c5bb.tar.gz
bcm5719-llvm-1b179bc5ff845e49fe787783ca3c7c8f2949c5bb.zip
[LVI] Constant-propagate a zero extension of the switch condition value through case edges
Summary: LazyValueInfo currently computes the constant value of the switch condition through case edges, which allows the constant value to be propagated through the case edges. But we have seen a case where a zero-extended value of the switch condition is used past case edges for which the constant propagation doesn't occur. This patch adds a small logic to handle such a case in getEdgeValueLocal(). This is motivated by the Python 2.7 eval loop in PyEval_EvalFrameEx() where the lack of the constant propagation causes longer live ranges and more spill code than necessary. With this patch, we see that the code size of PyEval_EvalFrameEx() decreases by ~5.4% and a performance test improves by ~4.6%. Reviewers: wmi, dberlin, sanjoy Reviewed By: sanjoy Subscribers: davide, davidxl, llvm-commits Differential Revision: https://reviews.llvm.org/D34822 llvm-svn: 309415
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/CorrelatedValuePropagation/range.ll114
1 files changed, 114 insertions, 0 deletions
diff --git a/llvm/test/Transforms/CorrelatedValuePropagation/range.ll b/llvm/test/Transforms/CorrelatedValuePropagation/range.ll
index 216b7f32434..228c3ca961f 100644
--- a/llvm/test/Transforms/CorrelatedValuePropagation/range.ll
+++ b/llvm/test/Transforms/CorrelatedValuePropagation/range.ll
@@ -462,3 +462,117 @@ then:
else:
ret i1 false
}
+
+define i32 @test16(i8 %a) {
+entry:
+ %b = zext i8 %a to i32
+ br label %dispatch
+
+dispatch:
+ %cmp = icmp eq i8 %a, 93
+ br i1 %cmp, label %target93, label %dispatch
+
+; CHECK-LABEL: @test16(
+; CHECK: target93:
+; CHECK-NEXT: ret i32 93
+target93:
+ ret i32 %b
+}
+
+define i32 @test16_i1(i1 %a) {
+entry:
+ %b = zext i1 %a to i32
+ br label %dispatch
+
+dispatch:
+ br i1 %a, label %true, label %dispatch
+
+; CHECK-LABEL: @test16_i1(
+; CHECK: true:
+; CHECK-NEXT: ret i32 1
+true:
+ ret i32 %b
+}
+
+define i8 @test17(i8 %a) {
+entry:
+ %c = add i8 %a, 3
+ br label %dispatch
+
+dispatch:
+ %cmp = icmp eq i8 %a, 93
+ br i1 %cmp, label %target93, label %dispatch
+
+; CHECK-LABEL: @test17(
+; CHECK: target93:
+; CHECK-NEXT: ret i8 96
+target93:
+ ret i8 %c
+}
+
+define i8 @test17_2(i8 %a) {
+entry:
+ %c = add i8 %a, %a
+ br label %dispatch
+
+dispatch:
+ %cmp = icmp eq i8 %a, 93
+ br i1 %cmp, label %target93, label %dispatch
+
+; CHECK-LABEL: @test17_2(
+; CHECK: target93:
+; CHECK-NEXT: ret i8 -70
+target93:
+ ret i8 %c
+}
+
+define i1 @test17_i1(i1 %a) {
+entry:
+ %c = and i1 %a, true
+ br label %dispatch
+
+dispatch:
+ br i1 %a, label %true, label %dispatch
+
+; CHECK-LABEL: @test17_i1(
+; CHECK: true:
+; CHECK-NEXT: ret i1 true
+true:
+ ret i1 %c
+}
+
+define i32 @test18(i8 %a) {
+entry:
+ %b = zext i8 %a to i32
+ br label %dispatch
+
+dispatch:
+ switch i8 %a, label %dispatch [
+ i8 93, label %target93
+ i8 -111, label %dispatch
+ ]
+
+; CHECK-LABEL: @test18(
+; CHECK: target93:
+; CHECK-NEXT: ret i32 93
+target93:
+ ret i32 %b
+}
+
+define i8 @test19(i8 %a) {
+entry:
+ %c = add i8 %a, 3
+ br label %dispatch
+
+dispatch:
+ switch i8 %a, label %dispatch [
+ i8 93, label %target93
+ i8 -111, label %dispatch
+ ]
+
+; CHECK-LABEL: @test19(
+; CHECK: target93:
+; CHECK-NEXT: ret i8 96
+target93:
+ ret i8 %c
+}
OpenPOWER on IntegriCloud