diff options
author | Hans Wennborg <hans@hanshq.net> | 2019-03-29 13:40:05 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2019-03-29 13:40:05 +0000 |
commit | 800b12f90a43d83d17a0e31ad09983033b6789af (patch) | |
tree | 0af705e2125d2cc960a704f2c0a73cc72fb3825c /llvm/test/CodeGen/AArch64/switch-unreachable-default.ll | |
parent | 881bcbe09471c9e6ae70228cf9754d568ac8e350 (diff) | |
download | bcm5719-llvm-800b12f90a43d83d17a0e31ad09983033b6789af.tar.gz bcm5719-llvm-800b12f90a43d83d17a0e31ad09983033b6789af.zip |
Switch lowering: exploit unreachable fall-through when lowering case range cluster
In the example below, we would previously emit two range checks, one for cases
1--3 and one for 4--6. This patch makes us exploit the fact that the
fall-through is unreachable and only one range check is necessary.
switch i32 %i, label %default [
i32 1, label %bb1
i32 2, label %bb1
i32 3, label %bb1
i32 4, label %bb2
i32 5, label %bb2
i32 6, label %bb2
]
default: unreachable
llvm-svn: 357252
Diffstat (limited to 'llvm/test/CodeGen/AArch64/switch-unreachable-default.ll')
-rw-r--r-- | llvm/test/CodeGen/AArch64/switch-unreachable-default.ll | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/llvm/test/CodeGen/AArch64/switch-unreachable-default.ll b/llvm/test/CodeGen/AArch64/switch-unreachable-default.ll index 9db3cee14e5..9acc5a150b6 100644 --- a/llvm/test/CodeGen/AArch64/switch-unreachable-default.ll +++ b/llvm/test/CodeGen/AArch64/switch-unreachable-default.ll @@ -74,17 +74,15 @@ entry: i32 64, label %bb5 ] -; The switch is lowered with a jump table for cases 1--32 and case 64 checked -; separately. Even though the default of switch is unreachable, the fall-through -; for the jump table *is* reachable so the range check must be emitted. +; The switch is lowered with a jump table for cases 1--32 and case 64 handled +; separately. Even though the default of the switch is unreachable, the +; fall-through for the jump table *is* reachable so the range check must be +; emitted. ; ; CHECK-LABEL: reachable_fallthrough -; CHECK: sub -; CHECK: cmp +; CHECK: sub [[REG:w[0-9]+]], w0, #1 +; CHECK: cmp [[REG]], #31 ; CHECK: b.hi -; -; TODO: Drop the cmp for the 64 case since its fallthrough is unreachable. - def: unreachable bb1: br label %return @@ -94,6 +92,6 @@ bb4: br label %return bb5: br label %return return: - %p = phi i32 [ 3, %bb1 ], [ 2, %bb2 ], [ 1, %bb3 ], [ 0, %bb4 ], [ 0, %bb5 ] + %p = phi i32 [ 3, %bb1 ], [ 2, %bb2 ], [ 1, %bb3 ], [ 0, %bb4 ], [ 42, %bb5 ] ret i32 %p } |