[all-commits] [llvm/llvm-project] 4a19e6: [InstCombine] Fold abs(-x) -> abs(x)

topperc via All-commits all-commits at lists.llvm.org
Sat Aug 1 13:25:19 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 4a19e6156ed5b6e87d708e6de29b675be69c574f
      https://github.com/llvm/llvm-project/commit/4a19e6156ed5b6e87d708e6de29b675be69c574f
  Author: Craig Topper <craig.topper at intel.com>
  Date:   2020-08-01 (Sat, 01 Aug 2020)

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

  Log Message:
  -----------
  [InstCombine] Fold abs(-x) -> abs(x)

Negating the input doesn't matter. I left a FIXME to copy the nsw flag if its present on the neg but not on the abs.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D85055


  Commit: 85b5315dbe9d52766ab326e702d638fcf58579b5
      https://github.com/llvm/llvm-project/commit/85b5315dbe9d52766ab326e702d638fcf58579b5
  Author: Craig Topper <craig.topper at intel.com>
  Date:   2020-08-01 (Sat, 01 Aug 2020)

  Changed paths:
    M llvm/lib/Analysis/InstructionSimplify.cpp
    M llvm/test/Transforms/InstSimplify/call.ll

  Log Message:
  -----------
  [InstSimplify] Fold abs(abs(x)) -> abs(x)

It's always safe to pick the earlier abs regardless of the nsw flag. We'll just lose it if it is on the outer abs but not the inner abs.

Differential Revision: https://reviews.llvm.org/D85053


Compare: https://github.com/llvm/llvm-project/compare/95ddb9ff6730...85b5315dbe9d


More information about the All-commits mailing list