[PATCH] D126895: [SLP] Phi inputs that come from an unreachable block should be undef.
Harald van Dijk via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 2 11:50:09 PDT 2022
hvdijk added a comment.
In D126895#3554064 <https://reviews.llvm.org/D126895#3554064>, @vporpo wrote:
> I think that the issue boils down to whether: `%zext = zext i8 poison to i32` is an i32 poison.
It is, yes.
> Instcombine is folding zext into phis like so:
>
> For a phi with an undef input:
>
> bb1:
> br label %bb3
> bb2:
> br label %bb3
> bb3:
> %phi = phi <2 x i8> [ %arg, %bb1 ], [ <i8 1, i8 undef>, %bb2 ]
> %zext = zext <2 x i8> %phi to <2 x i32>
>
> Instcombine will fold the zext into phi like this:
>
> bb1:
> %phi.cast = zext <2 x i8> %arg to <2 x i32>
> br label %bb3
> bb2: ; No predecessors!
> br label %bb3
> bb3: ; preds = %bb2, %bb1
> %phi = phi <2 x i32> [ %phi.cast, %bb1 ], [ <i32 1, i32 0>, %bb2 ]
>
> But for a phi with a poison input it will generate this:
>
> bb1:
> %phi.cast = zext <2 x i8> %arg to <2 x i32>
> br label %bb3
> bb2: ; No predecessors!
> br label %bb3
> bb3: ; preds = %bb2, %bb1
> %phi = phi <2 x i32> [ %phi.cast, %bb1 ], [ <i32 1, i32 poison>, %bb2 ]
>
> The input from %bb2 is now an i32 poison, which does not seem to hold the same properties as a zero-extended i8 poison.
It holds the same properties in all cases where we reach the block through bb.2, all zero of them. That's why poison should be fine: we know it's only for a case that cannot ever happen.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126895/new/
https://reviews.llvm.org/D126895
More information about the llvm-commits
mailing list