[PATCH] D136754: [MachineCombiner] Extend reassociation logic to handle inverse instructions

Anton Sidorenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 26 07:04:56 PDT 2022


asi-sc added a comment.

In D136754#3885523 <https://reviews.llvm.org/D136754#3885523>, @pengfei wrote:

> Do we have any benefits in doing this? The diff in tests just show a swap of 2 source operands, which I think might have no impact to the performance.

This is a general support in machine-combiner that provides functions to be overridden in backends. So, exactly this patch will not show performance changes. But I agree, I definitely must've demonstrated at least some performance measurements. So, if we implement basic support in RISCV and say that `fsub` is the inverse of `fadd`, then for Whetstone we have the following results:

N1 +8%
N2 +14%

Baseline

  Loop content                  Result              MFLOPS      MOPS   Seconds
  
  N1 floating point     -1.12398255667391900       284.545              0.694
  N2 floating point     -1.12187079889295083       224.314              6.162
  N3 if then else        1.00000000000000000                5715.791    0.186
  N4 fixed point        12.00000000000000000               323977497.600    0.000
  N5 sin,cos etc.        0.49902937281518078                  20.796   41.147
  N6 floating point      0.99999987890802811       169.611             32.708
  N7 assignments         3.00000000000000000                7136.783    0.266
  N8 exp,sqrt etc.       0.75100163018453681                  21.396   17.882
  
  MWIPS                                           1038.403             99.046

This patch + RISCV support

  Loop content                  Result              MFLOPS      MOPS   Seconds
  
  N1 floating point     -1.12398255667392588       308.002              0.652
  N2 floating point     -1.12187079889289487       257.436              5.460
  N3 if then else        1.00000000000000000                5714.154    0.189
  N4 fixed point        12.00000000000000000               299507735.273    0.000
  N5 sin,cos etc.        0.49902937281518078                  20.861   41.714
  N6 floating point      0.99999987890802811       170.068             33.173
  N7 assignments         3.00000000000000000                7176.013    0.269
  N8 exp,sqrt etc.       0.75100163018453681                  21.117   18.425
  
  MWIPS                                           1047.136             99.882

Compilation flags `-O3 -funroll-loops -finline-functions -ffast-math -mtune=sifive-u74`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136754/new/

https://reviews.llvm.org/D136754



More information about the llvm-commits mailing list