[PATCH] D106056: [CVP] processSwitch: Remove default case when switch cover all possible values.

JunMa via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 9 19:07:14 PDT 2021


junparser added a comment.

In D106056#2931299 <https://reviews.llvm.org/D106056#2931299>, @spatel wrote:

> In D106056#2931023 <https://reviews.llvm.org/D106056#2931023>, @junparser wrote:
>
>> @spatel, thanks for review the patch, and sorry for confusing you about the testcase.
>>
>> It turns out that the last change did something wrong to get the range of switch cases.
>> This patch fixes it and now the testcase shows what it would handle.
>
> If I run the test with -simplifycfg, I see:
>
>   define i32 @switch_range(i32 %cond) {
>   entry:
>     %s = urem i32 %cond, 2
>     %s1 = add i32 %s, 1
>     %s1.off = add i32 %s1, -1
>     %switch = icmp ult i32 %s1.off, 2
>     %. = select i1 %switch, i32 1, i32 0
>     ret i32 %.
>   }
>
> I think you need to expand the test with >2 valid cases to show the potential optimization/motivation better (and I still recommend that you pre-commit the baseline test at least locally, so we can see the diff in IR from this patch).

Thanks!I'll try it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106056/new/

https://reviews.llvm.org/D106056



More information about the llvm-commits mailing list