[all-commits] [llvm/llvm-project] 626c37: [InstCombine] Transform 1.0/sqrt(X) * X to X/sqrt(X)

venkataramanankumar via All-commits all-commits at lists.llvm.org
Wed Sep 2 05:25:54 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 626c3738cdfa49527097fccdf89e22949138ade7
      https://github.com/llvm/llvm-project/commit/626c3738cdfa49527097fccdf89e22949138ade7
  Author: Venkataramanan Kumar <venkataramanan.kumar.llvm at gmail.com>
  Date:   2020-09-02 (Wed, 02 Sep 2020)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
    M llvm/test/Transforms/InstCombine/fmul-sqrt.ll

  Log Message:
  -----------
  [InstCombine] Transform 1.0/sqrt(X) * X to X/sqrt(X)

These transforms will now be performed irrespective of the number of uses for the expression "1.0/sqrt(X)":
1.0/sqrt(X) * X => X/sqrt(X)
X * 1.0/sqrt(X) => X/sqrt(X)

We already handle more general cases, and we are intentionally not creating extra (and likely expensive)
fdiv ops in IR. This pattern is the exception to the rule because we always expect the Backend to reduce
X/sqrt(X) to sqrt(X), if it has the necessary (reassoc) fast-math-flags.

Ref: DagCombiner optimizes the X/sqrt(X) to sqrt(X).

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




More information about the All-commits mailing list