[PATCH] D122485: [SimplifyCFG] Fold mutil cases to And mask
chenglin.bi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 13 08:46:28 PDT 2022
bcl5980 added a comment.
In D122485#3448240 <https://reviews.llvm.org/D122485#3448240>, @spatel wrote:
> Let's add the baseline tests as an NFC commit now, so it is easier to see the diffs.
>
> The order of the transforms creates an interesting trade-off, so we need a test like this (and probably even more tests):
>
> define i8 @same_value_two_case(i32 %i) {
> entry:
> switch i32 %i, label %default [
> i32 -3, label %end
> i32 5, label %end
> ]
>
> default:
> br label %end
>
> end:
> %t0 = phi i8 [ 42, %default ], [ 3, %entry ], [ 3, %entry ]
> ret i8 %t0
> }
>
> This patch creates a difference that survives all the way through codegen - instcombine does not recognize the equivalence between the 2 patterns:
> https://alive2.llvm.org/ce/z/mqo87Z
>
> It's not clear to me if there is a universal better form (depends on target?) or even which one is better for IR. To avoid those questions, you can re-order the transforms, so we do not have to answer it in this patch (add a TODO comment though).
Try two patterns on current backend, this patch's implementation generate better asm on x86 and aarch64: https://godbolt.org/z/nsoWa7Kqr
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122485/new/
https://reviews.llvm.org/D122485
More information about the llvm-commits
mailing list