From 07f6d3a89379d615f266df16d0b076e457fa05ae Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Fri, 15 Apr 2016 21:45:30 +0000 Subject: Switch lowering: don't add incoming PHI values from skipped bit test MBB's (PR27135) After r245976, LLVM will skip the last bit test case if knows it will always be true. However, we would still erroneously update PHI nodes with incoming values from the MBB that would perform the final bit test, causing -verify-machineinstrs to fail. llvm-svn: 266479 --- llvm/test/CodeGen/X86/switch.ll | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'llvm/test') diff --git a/llvm/test/CodeGen/X86/switch.ll b/llvm/test/CodeGen/X86/switch.ll index 5bba78d4490..2506a075106 100644 --- a/llvm/test/CodeGen/X86/switch.ll +++ b/llvm/test/CodeGen/X86/switch.ll @@ -1,5 +1,5 @@ -; RUN: llc -mtriple=x86_64-linux-gnu %s -o - -jump-table-density=40 | FileCheck %s -; RUN: llc -mtriple=x86_64-linux-gnu %s -o - -O0 -jump-table-density=40 | FileCheck --check-prefix=NOOPT %s +; RUN: llc -mtriple=x86_64-linux-gnu %s -o - -jump-table-density=40 -verify-machineinstrs | FileCheck %s +; RUN: llc -mtriple=x86_64-linux-gnu %s -o - -O0 -jump-table-density=40 -verify-machineinstrs | FileCheck --check-prefix=NOOPT %s declare void @g(i32) @@ -748,3 +748,33 @@ return: ret void ; Don't assert due to truncating the bitwidth (64) to i4 when checking ; that the bit-test range fits in a word. } + + +define i32 @pr27132(i32 %i) { +entry: + br i1 undef, label %sw, label %end +sw: + switch i32 %i, label %end [ + i32 99, label %sw.bb + i32 98, label %sw.bb + i32 101, label %sw.bb + i32 97, label %sw.bb2 + i32 96, label %sw.bb2 + i32 100, label %sw.bb2 + ] +sw.bb: + unreachable +sw.bb2: + unreachable +end: + %p = phi i32 [ 1, %sw ], [ 0, %entry ] + ret i32 %p + +; CHECK-LABEL: pr27132: +; The switch is lowered with bit tests. Since the case range is contiguous, the +; second bit test is redundant and can be skipped. Check that we don't update +; the phi node with an incoming value from the MBB of the skipped bit test +; (-verify-machine-instrs cathces this). +; CHECK: btl +; CHECK-NOT: btl +} -- cgit v1.2.3