Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RISC-V] Opt emitLoadImmediate #109062

Merged
merged 4 commits into from
Oct 28, 2024
Merged

Conversation

clamp03
Copy link
Member

@clamp03 clamp03 commented Oct 21, 2024

I found unnecessary moves are generated on RISC-V.
example.

lui            a1, 516597
addiw          a1, a1, -93
slli           a1, a1, 7
mv             a1, a1

To remove such moves, the PR skips slli and add in case of low11 is zero in each iteration.
*. I found the same optimization in src/coreclr/vm/riscv64/stubs.cpp and copied the codes.

Part of #84834
cc @dotnet/samsung

@clamp03 clamp03 self-assigned this Oct 21, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 21, 2024
@clamp03 clamp03 requested a review from t-mustafin October 21, 2024 06:11
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Oct 21, 2024
@clamp03 clamp03 added arch-riscv Related to the RISC-V architecture community-contribution Indicates that the PR has been added by a community member and removed community-contribution Indicates that the PR has been added by a community member labels Oct 21, 2024
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@risc-vv
Copy link

risc-vv commented Oct 21, 2024

784f0ab is being scheduled for building and testing

GIT: 784f0ab57781bf70b3451da8542a4f1bb2a92c9e
REPO: dotnet/runtime
BRANCH: main

Release-CLR-build FAILED

buildinfo.json

Compilation failed during coreclr-tests build```

</details>

Skip `slli` and `add` if `low12` is 0 for the iterations.
@clamp03 clamp03 force-pushed the optEmitLoadImmediate branch from 784f0ab to e67f60f Compare October 21, 2024 06:29
@risc-vv
Copy link

risc-vv commented Oct 21, 2024

e67f60f is being scheduled for building and testing

GIT: e67f60f2406475a3e23af29676cdcff7a3e9f01b
REPO: dotnet/runtime
BRANCH: main

Release-CLR-build FAILED

buildinfo.json

Compilation failed during coreclr-tests build```

</details>

@risc-vv
Copy link

risc-vv commented Oct 21, 2024

722baf4 is being scheduled for building and testing

GIT: 722baf4a4a0aa3d26b6d27b37ca796e41483cb79
REPO: dotnet/runtime
BRANCH: main

Release-CLR-build FAILED

buildinfo.json

Compilation failed during coreclr-tests build```

</details>

Copy link
Contributor

@tomeksowi tomeksowi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. No more suggestions to this opt.

src/coreclr/jit/emitriscv64.cpp Outdated Show resolved Hide resolved
src/coreclr/jit/emitriscv64.cpp Show resolved Hide resolved
@risc-vv
Copy link

risc-vv commented Oct 21, 2024

51250ae is being scheduled for building and testing

GIT: 51250ae718b45231befa5c4011e741f73a1b5154
REPO: dotnet/runtime
BRANCH: main

Release-CLR-build FAILED

buildinfo.json

Compilation failed during coreclr-tests build```

</details>

@clamp03 clamp03 requested a review from jakobbotsch October 24, 2024 01:58
@risc-vv
Copy link

risc-vv commented Oct 24, 2024

Release-build FAILED

buildinfo.json

Cloning into '/go-agent/pipelines/Release-build/runtime'...
Updating files:  14% (8746/59431)
Updating files:  15% (8915/59431)
Updating files:  16% (9509/59431)
Updating files:  17% (10104/59431)
Updating files:  18% (10698/59431)
Updating files:  19% (11292/59431)
Updating files:  20% (11887/59431)
Updating files:  21% (12481/59431)
Updating files:  22% (13075/59431)
Updating files:  23% (13670/59431)
Updating files:  24% (14264/59431)
Updating files:  25% (14858/59431)
Updating files:  26% (15453/59431)
Updating files:  27% (16047/59431)
Updating files:  28% (16641/59431)
Updating files:  29% (17235/59431)
Updating files:  30% (17830/59431)
Updating files:  31% (18424/59431)
Updating files:  32% (19018/59431)
Updating files:  32% (19529/59431)
Updating files:  33% (19613/59431)
Updating files:  34% (20207/59431)
Updating files:  35% (20801/59431)
Updating files:  36% (21396/59431)
Updating files:  37% (21990/59431)
Updating files:  38% (22584/59431)
Updating files:  39% (23179/59431)
Updating files:  40% (23773/59431)
Updating files:  41% (24367/59431)
Updating files:  42% (24962/59431)
Updating files:  43% (25556/59431)
Updating files:  44% (26150/59431)
Updating files:  45% (26744/59431)
Updating files:  46% (27339/59431)
Updating files:  47% (27933/59431)
Updating files:  48% (28527/59431)
Updating files:  49% (29122/59431)
Updating files:  50% (29716/59431)
Updating files:  51% (30310/59431)
Updating files:  51% (30764/59431)
Updating files:  52% (30905/59431)
Updating files:  53% (31499/59431)
Updating files:  54% (32093/59431)
Updating files:  55% (32688/59431)
Updating files:  56% (33282/59431)
Updating files:  57% (33876/59431)
Updating files:  58% (34470/59431)
Updating files:  59% (35065/59431)
Updating files:  60% (35659/59431)
Updating files:  61% (36253/59431)
Updating files:  62% (36848/59431)
Updating files:  63% (37442/59431)
Updating files:  64% (38036/59431)
Updating files:  65% (38631/59431)
Updating files:  66% (39225/59431)
Updating files:  67% (39819/59431)
Updating files:  68% (40414/59431)
Updating files:  69% (41008/59431)
Updating files:  70% (41602/59431)
Updating files:  71% (42197/59431)
Updating files:  72% (42791/59431)
Updating files:  73% (43385/59431)
Updating files:  74% (43979/59431)
Updating files:  75% (44574/59431)
Updating files:  76% (45168/59431)
Updating files:  77% (45762/59431)
Updating files:  78% (46357/59431)
Updating files:  78% (46490/59431)
Updating files:  79% (46951/59431)
Updating files:  80% (47545/59431)
Updating files:  81% (48140/59431)
Updating files:  82% (48734/59431)
Updating files:  83% (49328/59431)
Updating files:  84% (49923/59431)
Updating files:  85% (50517/59431)
Updating files:  86% (51111/59431)
Updating files:  87% (51705/59431)
Updating files:  88% (52300/59431)
Updating files:  89% (52894/59431)
Updating files:  90% (53488/59431)
Updating files:  91% (54083/59431)
Updating files:  92% (54677/59431)
Updating files:  92% (54736/59431)
Updating files:  93% (55271/59431)
Updating files:  94% (55866/59431)
Updating files:  95% (56460/59431)
Updating files:  96% (57054/59431)
Updating files:  97% (57649/59431)
Updating files:  98% (58243/59431)
Updating files:  99% (58837/59431)
Updating files: 100% (59431/59431)
Updating files: 100% (59431/59431), done.
From https://github.com/clamp03/runtime
 * branch                    optEmitLoadImmediate -> FETCH_HEAD
 * [new branch]              optEmitLoadImmediate -> upstream/optEmitLoadImmediate
Merge made by the 'ort' strategy.
 src/coreclr/jit/emitriscv64.cpp  | 27 +++++++++++++++++++++------
 src/coreclr/vm/riscv64/stubs.cpp |  5 ++++-
 2 files changed, 25 insertions(+), 7 deletions(-)

@clamp03
Copy link
Member Author

clamp03 commented Oct 25, 2024

@jakobbotsch Could you take a look at this PR? Thank you!

@risc-vv
Copy link

risc-vv commented Oct 25, 2024

RISC-V Release-CLR-VF2: 9419 / 9440 (99.78%)
=======================
      passed: 9419
      failed: 4
     skipped: 107
      killed: 17
------------------------
  TOTAL libs: 9547
 TOTAL tests: 9547
   REAL time: 3h 0min 59s 20ms
=======================

Release-CLR-VF2.md, Release-CLR-VF2.xml, testclr_output.tar.gz

RISC-V Release-FX-VF2: 549378 / 591612 (92.86%)
=======================
      passed: 549378
      failed: 879
     skipped: 1468
      killed: 41355
------------------------
  TOTAL libs: 257
 TOTAL tests: 593080
   REAL time: 2h 32min 31s 198ms
=======================

Release-FX-VF2.md, Release-FX-VF2.xml, testfx_output.tar.gz

Build information and commands

GIT: d13b8b8b5c2ed298935771a4a60489a6d64eb934
CI: 588c31b6ba31e6551a37bfcc7a0421b734da4141
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

# CORE_LIBS_BUILD_CMD
runtime/build.sh --arch riscv64 --cross -c Release -s libs /p:EnableSourceLink=false
# CORE_BUILD_CMD
runtime/build.sh --arch riscv64 --cross -c Release -s clr+libs+host /p:EnableSourceLink=false

# TESTCLR_BUILD_CMD
runtime/src/tests/build.sh -riscv64 -cross -Release -priority1 -p:UsePublishedCrossgen2=false -p:UseLocalAppHostPack=true
# TESTCLR_CMD
python3 riscv-CI/goci/agent/TestRunner/run.py --core_root ./coreclr.Release/Tests/Core_Root --testhost ./testhost.Release --atest ./coreclr.Release --test ./ --log_dir ./logs  --timeout 2700 --log_level DEBUG --xunit xunit.Release
# TESTCLR_RUN
/var/lib/go-agent/pipelines/Release-CLR-VF2/logs/run_tests.log
cp -R /var/lib/go-agent/pipelines/Release-CLR-VF2/xunit.Release "/_PATH_/_WITH_/_TEST_"/ ; cd "/_PATH_/_WITH_/_TEST_" && __TestDotNetCmd=/var/lib/go-agent/pipelines/Release-CLR-VF2/testhost.Release/dotnet CORE_ROOT=/var/lib/go-agent/pipelines/Release-CLR-VF2/coreclr.Release/Tests/Core_Root  /usr/bin/time -f "exec_time: %e" ./_TEST_BINARY_

# TESTFX_BUILD_CMD
runtime/build.sh --arch riscv64 --cross -c Release -rc Release -hc Release -lc Release -s libs.tests --testscope innerloop /p:EnableSourceLink=false /p:UseLocalAppHostPack=true
# TESTFX_CMD
unknown command
# TESTFX_RUN
unknown command

# TEST_ENV
DOTNET_JitStress=;DOTNET_JitStressRegs=;DOTNET_GCStress=;DOTNET_JITMinOpts=;DOTNET_TailcallStress=;DOTNET_TieredCompilation=
RISC-V Release-CLR-QEMU: 9419 / 9440 (99.78%)
=======================
      passed: 9419
      failed: 4
     skipped: 107
      killed: 17
------------------------
  TOTAL libs: 9547
 TOTAL tests: 9547
   REAL time: 57min 56s 471ms
=======================

Release-CLR-QEMU.md, Release-CLR-QEMU.xml, testclr_output.tar.gz

RISC-V Release-FX-QEMU: 566735 / 607908 (93.23%)
=======================
      passed: 566735
      failed: 1085
     skipped: 1459
      killed: 40088
------------------------
  TOTAL libs: 257
 TOTAL tests: 609367
   REAL time: 2h 23min 12s 272ms
=======================

Release-FX-QEMU.md, Release-FX-QEMU.xml, testfx_output.tar.gz

Build information and commands

GIT: d13b8b8b5c2ed298935771a4a60489a6d64eb934
CI: 588c31b6ba31e6551a37bfcc7a0421b734da4141
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

# CORE_LIBS_BUILD_CMD
runtime/build.sh --arch riscv64 --cross -c Release -s libs /p:EnableSourceLink=false
# CORE_BUILD_CMD
runtime/build.sh --arch riscv64 --cross -c Release -s clr+libs+host /p:EnableSourceLink=false

# TESTCLR_BUILD_CMD
runtime/src/tests/build.sh -riscv64 -cross -Release -priority1 -p:UsePublishedCrossgen2=false -p:UseLocalAppHostPack=true
# TESTCLR_CMD
python3 riscv-CI/goci/agent/TestRunner/run.py --core_root ./coreclr.Release/Tests/Core_Root --testhost ./testhost.Release --atest ./coreclr.Release --test ./ --log_dir ./logs  --timeout 2700 --log_level DEBUG --xunit xunit.Release
# TESTCLR_RUN
/godata/pipelines/Release-CLR-QEMU/logs/run_tests.log
cp -R /godata/pipelines/Release-CLR-QEMU/xunit.Release "/_PATH_/_WITH_/_TEST_"/ ; cd "/_PATH_/_WITH_/_TEST_" && ROOTFS_DIR=/crossrootfs/riscv64 QEMU_LD_PREFIX=/crossrootfs/riscv64 __TestDotNetCmd=/godata/pipelines/Release-CLR-QEMU/testhost.Release/dotnet CORE_ROOT=/godata/pipelines/Release-CLR-QEMU/coreclr.Release/Tests/Core_Root  /usr/bin/time -f "exec_time: %e" ./_TEST_BINARY_

# TESTFX_BUILD_CMD
runtime/build.sh --arch riscv64 --cross -c Release -rc Release -hc Release -lc Release -s libs.tests --testscope innerloop /p:EnableSourceLink=false /p:UseLocalAppHostPack=true
# TESTFX_CMD
unknown command
# TESTFX_RUN
unknown command

# TEST_ENV
DOTNET_JitStress=;DOTNET_JitStressRegs=;DOTNET_GCStress=;DOTNET_JITMinOpts=;DOTNET_TailcallStress=;DOTNET_TieredCompilation=
RISC-V Release-CLR-QEMU: 9419 / 9440 (99.78%)
=======================
      passed: 9419
      failed: 4
     skipped: 107
      killed: 17
------------------------
  TOTAL libs: 9547
 TOTAL tests: 9547
   REAL time: 57min 56s 504ms
=======================

Release-CLR-QEMU.md, Release-CLR-QEMU.xml, testclr_output.tar.gz

RISC-V Release-FX-QEMU: 566735 / 607908 (93.23%)
=======================
      passed: 566735
      failed: 1085
     skipped: 1459
      killed: 40088
------------------------
  TOTAL libs: 257
 TOTAL tests: 609367
   REAL time: 2h 23min 12s 272ms
=======================

Release-FX-QEMU.md, Release-FX-QEMU.xml, testfx_output.tar.gz

Build information and commands

GIT: d13b8b8b5c2ed298935771a4a60489a6d64eb934
CI: 588c31b6ba31e6551a37bfcc7a0421b734da4141
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

# CORE_LIBS_BUILD_CMD
runtime/build.sh --arch riscv64 --cross -c Release -s libs /p:EnableSourceLink=false
# CORE_BUILD_CMD
runtime/build.sh --arch riscv64 --cross -c Release -s clr+libs+host /p:EnableSourceLink=false

# TESTCLR_BUILD_CMD
runtime/src/tests/build.sh -riscv64 -cross -Release -priority1 -p:UsePublishedCrossgen2=false -p:UseLocalAppHostPack=true
# TESTCLR_CMD
python3 riscv-CI/goci/agent/TestRunner/run.py --core_root ./coreclr.Release/Tests/Core_Root --testhost ./testhost.Release --atest ./coreclr.Release --test ./ --log_dir ./logs  --timeout 2700 --log_level DEBUG --xunit xunit.Release
# TESTCLR_RUN
/godata/pipelines/Release-CLR-QEMU/logs/run_tests.log
cp -R /godata/pipelines/Release-CLR-QEMU/xunit.Release "/_PATH_/_WITH_/_TEST_"/ ; cd "/_PATH_/_WITH_/_TEST_" && ROOTFS_DIR=/crossrootfs/riscv64 QEMU_LD_PREFIX=/crossrootfs/riscv64 __TestDotNetCmd=/godata/pipelines/Release-CLR-QEMU/testhost.Release/dotnet CORE_ROOT=/godata/pipelines/Release-CLR-QEMU/coreclr.Release/Tests/Core_Root  /usr/bin/time -f "exec_time: %e" ./_TEST_BINARY_

# TESTFX_BUILD_CMD
runtime/build.sh --arch riscv64 --cross -c Release -rc Release -hc Release -lc Release -s libs.tests --testscope innerloop /p:EnableSourceLink=false /p:UseLocalAppHostPack=true
# TESTFX_CMD
unknown command
# TESTFX_RUN
unknown command

# TEST_ENV
DOTNET_JitStress=;DOTNET_JitStressRegs=;DOTNET_GCStress=;DOTNET_JITMinOpts=;DOTNET_TailcallStress=;DOTNET_TieredCompilation=
RISC-V Release-CLR-VF2: 9419 / 9440 (99.78%)
=======================
      passed: 9419
      failed: 4
     skipped: 107
      killed: 17
------------------------
  TOTAL libs: 9547
 TOTAL tests: 9547
   REAL time: 3h 3min 0s 234ms
=======================

Release-CLR-VF2.md, Release-CLR-VF2.xml, testclr_output.tar.gz

RISC-V Release-FX-VF2: 549378 / 591612 (92.86%)
=======================
      passed: 549378
      failed: 879
     skipped: 1468
      killed: 41355
------------------------
  TOTAL libs: 257
 TOTAL tests: 593080
   REAL time: 2h 32min 31s 198ms
=======================

Release-FX-VF2.md, Release-FX-VF2.xml, testfx_output.tar.gz

Build information and commands

GIT: d13b8b8b5c2ed298935771a4a60489a6d64eb934
CI: 588c31b6ba31e6551a37bfcc7a0421b734da4141
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

# CORE_LIBS_BUILD_CMD
runtime/build.sh --arch riscv64 --cross -c Release -s libs /p:EnableSourceLink=false
# CORE_BUILD_CMD
runtime/build.sh --arch riscv64 --cross -c Release -s clr+libs+host /p:EnableSourceLink=false

# TESTCLR_BUILD_CMD
runtime/src/tests/build.sh -riscv64 -cross -Release -priority1 -p:UsePublishedCrossgen2=false -p:UseLocalAppHostPack=true
# TESTCLR_CMD
python3 riscv-CI/goci/agent/TestRunner/run.py --core_root ./coreclr.Release/Tests/Core_Root --testhost ./testhost.Release --atest ./coreclr.Release --test ./ --log_dir ./logs  --timeout 2700 --log_level DEBUG --xunit xunit.Release
# TESTCLR_RUN
/var/lib/go-agent/pipelines/Release-CLR-VF2/logs/run_tests.log
cp -R /var/lib/go-agent/pipelines/Release-CLR-VF2/xunit.Release "/_PATH_/_WITH_/_TEST_"/ ; cd "/_PATH_/_WITH_/_TEST_" && __TestDotNetCmd=/var/lib/go-agent/pipelines/Release-CLR-VF2/testhost.Release/dotnet CORE_ROOT=/var/lib/go-agent/pipelines/Release-CLR-VF2/coreclr.Release/Tests/Core_Root  /usr/bin/time -f "exec_time: %e" ./_TEST_BINARY_

# TESTFX_BUILD_CMD
runtime/build.sh --arch riscv64 --cross -c Release -rc Release -hc Release -lc Release -s libs.tests --testscope innerloop /p:EnableSourceLink=false /p:UseLocalAppHostPack=true
# TESTFX_CMD
unknown command
# TESTFX_RUN
unknown command

# TEST_ENV
DOTNET_JitStress=;DOTNET_JitStressRegs=;DOTNET_GCStress=;DOTNET_JITMinOpts=;DOTNET_TailcallStress=;DOTNET_TieredCompilation=

@jakobbotsch jakobbotsch merged commit f1ad214 into dotnet:main Oct 28, 2024
108 checks passed
@clamp03 clamp03 deleted the optEmitLoadImmediate branch October 29, 2024 08:34
@github-actions github-actions bot locked and limited conversation to collaborators Nov 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-riscv Related to the RISC-V architecture area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants