This is an archive of the discontinued LLVM Phabricator instance.

[MachineCombiner][RISCV] Support inverse instructions reassociation
ClosedPublic

Authored by asi-sc on Nov 24 2022, 4:47 AM.

Details

Summary

This patch adds reassociation of FADD/FSUB instruction pairs.

Diff Detail

Event Timeline

asi-sc created this revision.Nov 24 2022, 4:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 24 2022, 4:47 AM
asi-sc requested review of this revision.Nov 24 2022, 4:47 AM

This patch is created to demonstrate the approach. So, I'm intentionally didn't add reviewers. However, it's possible that we'll follow the path this patch shows, so I don't abandon it immediately.

asi-sc updated this revision to Diff 479646.Dec 2 2022, 8:04 AM

sync changes with parent revision, rebase

asi-sc updated this revision to Diff 480851.Dec 7 2022, 4:21 AM

Add tests to cover fadd/fsub reassociation; rebase

asi-sc edited the summary of this revision. (Show Details)Dec 7 2022, 8:31 AM

Since we've moved RISCV reassociation implementation to generic machine combiner mechanism D138302 and added reassociation of inverse instructions to machine combiner in D136754, we now can enable reassociation of inverse for RISCV.

Performance measurements for Whetstone

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

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

A gentle ping.

This revision is now accepted and ready to land.Dec 15 2022, 12:26 AM
This revision was landed with ongoing or failed builds.Dec 15 2022, 5:49 AM
This revision was automatically updated to reflect the committed changes.