[PATCH] D22747: [InstCombine] try to fold (select C, (sext A), B) into logical ops

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 3 13:19:42 PDT 2016


spatel added a comment.

In https://reviews.llvm.org/D22747#505014, @nhaehnle wrote:

> Simplified the test cases (baseline is already in SVN), and use the APInt
>  hint, thanks!
>
> About the vector case: As you can see, it requires a change to
>  FoldOpIntoSelect (to avoid an infinite loop) and a change to one other test
>  case. Now the change looks correct, but I don't know if there may be
>  unintended optimization regressions in some backend...


Can you add a test case like:

  define <2 x i32> @scalar_select_of_vectors(<2 x i1> %cca, i1 %ccb) {
    %ccax = zext <2 x i1> %cca to <2 x i32>
    %r = select i1 %ccb, <2 x i32> %ccax, <2 x i32> <i32 0, i32 0>   ; scalar condition
    ret <2 x i32> %r
  }

Also, I'm curious why this wouldn't be good for non-i1 types. Did you see a case where it caused a problem? Particularly in the case of vectors, I think we should be performing ops in smaller types as much as possible before extending to a wider type (ref: https://llvm.org/bugs/show_bug.cgi?id=28160 ). Add a 'TODO' comment about that?


https://reviews.llvm.org/D22747





More information about the llvm-commits mailing list