aokblast wrote:
> > > Im still not sure what is happening, Can you give me a description of
> > > what transformation this is trying to enable? The tests are particularly
> > > opaque to me, as they seem to be skipping some important parts of the
> > > lines, so perhaps that would be helpful?
> >
> >
> > Let's take the first sccp as an example:
> > ```
> > cir.func @constant_switch() -> !s32i {
> > %cond = cir.const #cir.int<1> : !s32i
> > %c10 = cir.const #cir.int<10> : !s32i
> > %c20 = cir.const #cir.int<20> : !s32i
> > %c30 = cir.const #cir.int<30> : !s32i
> > cir.switch.flat %cond : !s32i, ^default(%c30 : !s32i) [
> > 0: ^case0(%c10 : !s32i),
> > 1: ^case1(%c20 : !s32i)
> > ]
> > ^case0(%a: !s32i):
> > cir.return %a : !s32i
> > ^case1(%b: !s32i):
> > cir.return %b : !s32i
> > ^default(%d: !s32i):
> > cir.return %d : !s32i
> > }
> >
> > // CHECK-LABEL: cir.func @constant_switch
> > // CHECK: %[[C20:.*]] = cir.const #cir.int<20> : !s32i
> > // CHECK: ^bb1(%[[A:.*]]: !s32i):
> > // CHECK-NEXT: cir.return %[[A]] : !s32i
> > // CHECK: ^bb2(%{{.*}}: !s32i):
> > // CHECK-NEXT: cir.return %[[C20]] : !s32i
> > // CHECK: ^bb3(%[[D:.*]]: !s32i):
> > // CHECK-NEXT: cir.return %[[D]] : !s32i
> > ```
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > In here, cir.switch.flat can only reaches case1 (bb2 in check label). So it
> > doesn't need to relies on %b and can be folded using %c20.
> > Before this patch, it generates something like
> > ```
> > // CHECK: ^bb1(%[[B:.*]]: !s32i):
> > // CHECK-NEXT: cir.return %[[B]] : !s32i
> > ```
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > instead of
> > ```
> > // CHECK: ^bb2(%{{.*}}: !s32i):
> > // CHECK-NEXT: cir.return %[[C20]] : !s32i
> > ```
>
> Ah, so it is effectively a constant propagation through the case block label?
Yes!
>
> I think I get it a bit... but what ends up in the %{{.*}}? Does that just end
> up being a dead SSA?
Yes, but it is DCE's responsibility to eliminate the dead SSA instead of SCCP.
https://github.com/llvm/llvm-project/pull/230340
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits