[PATCH] D140974: [LICM][WIP] Transform and hoist select instructions if possible

luxufan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 4 06:51:48 PST 2023


StephenFan added a comment.

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


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