[PATCH] D26556: [InstCombine] don't widen most selects by hoisting an extend

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 12 11:37:54 PST 2016


efriedma added a comment.

I'm not sure this approach is really right... narrower isn't always better.  You're just getting lucky with your AVX2 example: `<4 x i1>` as an argument happens to get passed as a 128-bit vector.  If the compare operand were a 64-bit comparison, you'd be making the code worse; consider:

  define <4 x i64> @f(<4 x i32> %a, <4 x i64> %b, <4 x i64> %c) {
    %cmp = icmp sgt <4 x i64> %b, %c
    %ext = sext <4 x i32> %a to <4 x i64>
    %sel = select <4 x i1> %cmp, <4 x i64> %ext, <4 x i64> <i64 42, i64 42, i64 42, i64 42>
    ret <4 x i64> %sel
  }

This is perfectly straightforward code of the sort you could write using intrinsics in C.  Move the sext, and the generated code becomes worse.


https://reviews.llvm.org/D26556





More information about the llvm-commits mailing list