[PATCH] D137934: [InstCombine] Fold extractelt with select of constants

Thomas Symalla via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 15 14:21:08 PST 2022


tsymalla added a comment.

@spatel Thanks for adding these tests. These work in general, except the case where the second operand of the ExtractElement instruction is not a constant. The reason is that currently `constantFoldOperationIntoSelectOperand` expects both operands to be either the original select or a constant, but not an additional select, so a new extractelement instruction can be created to extract the actual value. If one of the operands is another select, it could be obvious that the sequence shows OOB behavior:

  %e = select i1 %c, i32 3, i32 4
  %s = select i1 %c, <3 x i32> <i32 2, i32 3, i32 4>, <3 x i32> <i32 5, i32 6, i32 7>
  %r = extractelement <3 x i32> %s, i32 %e
  ret i32 %r

Even if I know how to make the regular case work, I'll wrap my head around that particular issue.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137934/new/

https://reviews.llvm.org/D137934



More information about the llvm-commits mailing list