[PATCH] D12249: Remove the final bit test during lowering switch statement if all cases in bit test cover a contiguous range.

Cong Hou via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 21 15:52:22 PDT 2015


congh added a comment.

In http://reviews.llvm.org/D12249#230466, @davidxl wrote:

> I have not looked at the details. Does your patch work for the case when a min value is not zero:
>
> define void @foo(i32 %x) {
> entry:
>
>   switch i32 %x, label %return [
>     i32 1, label %bb0
>     i32 3, label %bb0
>     i32 5, label %bb0
>     i32 2, label %bb1
>     i32 4, label %bb1
>     i32 6, label %bb1
>   ]
>
> bb0: tail call void @a() br label %return
>  bb1: tail call void @b() br label %return
>  return: ret void
>  }
>  declare void @a()
>  declare void @b()


Yes. In visitBitTestHeader(), a subtraction is always generated to subtract the min value, turning the min value into zero.


http://reviews.llvm.org/D12249





More information about the llvm-commits mailing list