[PATCH] D48754: [InstCombine] canonicalize abs pattern

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 16 07:20:49 PDT 2018


spatel added a comment.

Please add a test like this (it will fail with the current patch):

  define i32 @abs_canonical_9(i32 %a, i32 %b) {
    %tmp2 = sub i32 %b, %a
    %tmp1 = sub i32 %a, %b
    %cmp = icmp sgt i32 %tmp1, -1
    %abs = select i1 %cmp, i32 %tmp1, i32 %tmp2
    %add = add i32 %abs, %tmp2 ; increase use count for %tmp2.
    ret i32 %add
  }


https://reviews.llvm.org/D48754





More information about the llvm-commits mailing list