[PATCH] D39766: [InstCombine] Teach visitICmpInst to not break integer absolute value idioms

Lilly Rowling via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 12 22:44:24 PST 2017


lillyrowling18 added a comment.

In https://reviews.llvm.org/D39766#921760, @spatel wrote:

> Should we recognize (and canonicalize) this abs() pattern:
>
>   define i64 @abs5(i64 %x) {
>     %signbit = ashr i64 %x, 63      ; smear the sign bit
>     %add = add i64 %x, %signbit     ; add 0 or -1
>     %abs = xor i64 %add, %signbit   ; x < 0 ? -x : x
>     ret i64 %abs
>   }
>
>
> (note: I mentioned this pattern to the group looking at matching vector idioms <http://www.theidioms.com> earlier this year - not sure what happened to that effort).
>
> Independent of that, how about calling ValueTracking's matchSelectPattern()? Then, we could check all of min/max/abs in one shot without repeating the logic here.


I also had the same question, thanks for help.


Repository:
  rL LLVM

https://reviews.llvm.org/D39766





More information about the llvm-commits mailing list