[all-commits] [llvm/llvm-project] af0bab: [InstCombine] fold copysign with constant sign arg...

RotateRight via All-commits all-commits at lists.llvm.org
Mon Dec 2 06:24:00 PST 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: af0babc90a5c35cbecce4cc4a27e0396fe03f588
      https://github.com/llvm/llvm-project/commit/af0babc90a5c35cbecce4cc4a27e0396fe03f588
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2019-12-02 (Mon, 02 Dec 2019)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
    M llvm/test/Transforms/InstCombine/copysign.ll

  Log Message:
  -----------
  [InstCombine] fold copysign with constant sign argument to (fneg+)fabs

If the sign of the sign argument is known (this could be extended to use ValueTracking),
then we can use fneg+fabs to clear/set the sign bit of the magnitude argument.
http://llvm.org/docs/LangRef.html#llvm-copysign-intrinsic

This transform is already done in DAGCombiner, but we can do it sooner in IR as
suggested in PR44153:
https://bugs.llvm.org/show_bug.cgi?id=44153

We have effectively no analysis for copysign in IR, so we are taking the unusual step
of increasing the number of IR instructions for the negative constant case.

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




More information about the All-commits mailing list