[PATCH] D122485: [SimplifyCFG] Fold mutil cases to And mask
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 13 05:52:34 PDT 2022
spatel added a comment.
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).
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122485/new/
https://reviews.llvm.org/D122485
More information about the llvm-commits
mailing list