[PATCH] D21899: [InstCombine] extend (select X, C1, C2 --> ext X) to vectors

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 2 11:51:58 PDT 2016


eli.friedman added a comment.

Re: your questions about canonicalization:

1. The canonical representation of a calculation is whatever instcombine declares it to be.  We generally try to favor arithmetic over selects because selects tend to be more expensive, but there's a limit to where that's worthwhile.
2. Not sure exactly why we prefer to move xor out of a zext rather than in... apparently the transform was added in r21713 to cover this testcase:

  define i32 @test22(i1 %X) {
  ; CHECK-LABEL: @test22(
  ; CHECK-NEXT: %1 = zext i1 %X to i32
  ; CHECK-NEXT: ret i32 %1
  	%Y = xor i1 %X, true		; <i1> [#uses=1]
  	%Z = zext i1 %Y to i32		; <i32> [#uses=1]
  	%Q = xor i32 %Z, 1		; <i32> [#uses=1]
  	ret i32 %Q
  }

Obviously, that doesn't really motivate the canonical representation either way.   That said, moving the xor in rather than out in general raises awkward questions about what to do in cases like "(zext i8 x to i32) ^ 257".  And changing the canonical representation probably involves some work to figure out what other transforms depend on the canonical representation of zext+xor.


http://reviews.llvm.org/D21899





More information about the llvm-commits mailing list