[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
Tue Aug 10 00:20:18 PDT 2021


junparser added inline comments.


================
Comment at: llvm/test/Transforms/CorrelatedValuePropagation/basic.ll:380
 
+define i32 @switch_range(i32 %cond) {
+; CHECK-LABEL: @switch_range(
----------------
spatel wrote:
> It would help if you pre-commit this test with the baseline CHECK lines, so it is clear what changed with this patch.
> I just tried this example locally without the patch, and it does not seem to be different?
with simplifycfg, switch_range outputs


```
define i32 @switch_range(i32 %cond) {
entry:
  %s = urem i32 %cond, 3
  %s1 = add i32 %s, 1
  switch i32 %s1, label %unreachable [
    i32 1, label %common.ret
    i32 2, label %exit2
    i32 3, label %common.ret
  ]

common.ret:                                       ; preds = %entry, %entry, %unreachable, %exit2
  %common.ret.op = phi i32 [ 2, %exit2 ], [ 0, %unreachable ], [ 1, %entry ], [ 1, %entry ]
  ret i32 %common.ret.op

exit2:                                            ; preds = %entry
  br label %common.ret

unreachable:                                      ; preds = %entry
  br label %common.ret
}

define i1 @arg_attribute(i8* nonnull %a) {
  %cmp = icmp eq i8* %a, null
  ret i1 %cmp
}
```
the default case doesnot change


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