[all-commits] [llvm/llvm-project] 6a44ed: [InstCombine] fold abs of select with negated op (...

RotateRight via All-commits all-commits at lists.llvm.org
Mon Aug 24 04:44:15 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 6a44edb8da335bba355cd180a3f43564d14cd1be
      https://github.com/llvm/llvm-project/commit/6a44edb8da335bba355cd180a3f43564d14cd1be
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2020-08-24 (Mon, 24 Aug 2020)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
    M llvm/test/Transforms/InstCombine/abs-intrinsic.ll

  Log Message:
  -----------
  [InstCombine] fold abs of select with negated op (PR39474)

Similar to the existing transform - peek through a select
to match a value and its negation.

https://alive2.llvm.org/ce/z/MXi5KG

  define i8 @src(i1 %b, i8 %x) {
  %0:
    %neg = sub i8 0, %x
    %sel = select i1 %b, i8 %x, i8 %neg
    %abs = abs i8 %sel, 1
    ret i8 %abs
  }
  =>
  define i8 @tgt(i1 %b, i8 %x) {
  %0:
    %abs = abs i8 %x, 1
    ret i8 %abs
  }
  Transformation seems to be correct!




More information about the All-commits mailing list