[PATCH] D140974: [LICM][WIP] Transform and hoist select instructions if possible
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 4 07:01:48 PST 2023
nikic added a subscriber: spatel.
nikic added a comment.
In D140974#4026009 <https://reviews.llvm.org/D140974#4026009>, @StephenFan wrote:
> In D140974#4025888 <https://reviews.llvm.org/D140974#4025888>, @nikic wrote:
>
>> Shouldn't this be handled by adding this fold to InstCombine? https://alive2.llvm.org/ce/z/EXY5JH
>
> Thanks for your advice! I will try to handle this in InstCombine. But it seems it is not a beneficial transformation if we transform
>
> define i8 @src(i1 %c, i8 %x) {
> %add = add i8 %x, 10
> %select = select i1 %c, i8 %x, i8 %add
> ret i8 %select
> }
>
> to
>
> define i8 @tgt(i1 %c, i8 %x) {
> %select = select i1 %c, i8 0, i8 10
> %add = add i8 %select, %x
> ret i8 %add
> }
>
> https://godbolt.org/z/zxeojTxqb
This looks beneficial from a middle-end perspective, so we probably need to undo in the backend? @spatel Any thoughts?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140974/new/
https://reviews.llvm.org/D140974
More information about the llvm-commits
mailing list