Skip to content

Conversation

@lxq015
Copy link
Contributor

@lxq015 lxq015 commented Sep 24, 2025

Zicond is a mandatory extension in rva23u64. This patch converts
branches to CondSelect and optimizes them to Zicond instructions
on RISC-V, along with additional optimization rules.

Zicond can provide performance benefits on unpredictable branches by
avoiding branch misprediction penalties. However, on simple predictable
branches, zicond uses 4 instructions vs 2 for traditional branches,
which can cause performance regressions.

To avoid regressions, we keep CondSelect globally disabled for riscv64
and only enable it for the ConstantTimeSelect intrinsic,
which has been shown to benefit from zicond:

goos: linux
goarch: riscv64
pkg: crypto/subtle
CPU: SG2044
│ nozicond.txt │ zicond.txt │
│ sec/op │ sec/op vs base │
ConstantTimeSelect-44 2.325n ± 4% 1.750n ± 2% -24.69% (p=0.000 n=10)

Future work can explore enabling zicond for other cases that can benefit
from zicond.

Follow-up to CL 631595
Updates #75350

Co-authored-by: wangpengcheng.pp@bytedance.com
mengzhuo1203@gmail.com

@gopherbot
Copy link
Contributor

This PR (HEAD: f5f9d07) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705996.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.
@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Mark Ryan:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@lxq015 lxq015 force-pushed the zicond-codegen-support branch from 2f5ba88 to 58e1e0c Compare September 25, 2025 08:44
@gopherbot
Copy link
Contributor

This PR (HEAD: 58e1e0c) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705996.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.
@gopherbot
Copy link
Contributor

Message from Xueqi Luo:

Patch Set 2:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Xueqi Luo:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Joel Sing:

Patch Set 2: Run-TryBot+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gopher Robot:

Patch Set 2:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Dmitri Shuralyov:

Patch Set 2: Commit-Queue+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 2:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2025-10-17T20:47:34Z","revision":"a7132c18e5acb55b578bd3cbdeb82ffcd9700498"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Dmitri Shuralyov:

Patch Set 2: -Commit-Queue


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 2:

This CL has passed the run


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 2: LUCI-TryBot-Result+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Michael Munday:

Patch Set 2:

(5 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: 00604c6) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705996.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.
@gopherbot
Copy link
Contributor

Message from Michael Munday:

Patch Set 4:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: 9e3f91a) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705996.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.
@gopherbot
Copy link
Contributor

Message from Xueqi Luo:

Patch Set 4:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Joel Sing:

Patch Set 5: Commit-Queue+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 5:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2025-10-22T15:27:55Z","revision":"a78d7cefbf4d1e3b2df625c9389c8fa01f7aef09"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Joel Sing:

Patch Set 5: -Commit-Queue


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 5:

This CL has passed the run


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 5: LUCI-TryBot-Result+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Michael Munday:

Patch Set 5:

(9 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@lxq015 lxq015 force-pushed the zicond-codegen-support branch from 9e3f91a to cd67025 Compare November 4, 2025 07:04
@gopherbot
Copy link
Contributor

This PR (HEAD: cd67025) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705996.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.
@gopherbot
Copy link
Contributor

Message from Xueqi Luo:

Patch Set 6:

(15 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Michael Munday:

Patch Set 6: Code-Review+1

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@lxq015 lxq015 force-pushed the zicond-codegen-support branch from f87591b to 29e37a3 Compare December 3, 2025 09:38
@gopherbot
Copy link
Contributor

Message from Xueqi Luo:

Patch Set 22:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: 29e37a3) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705996.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.
@gopherbot
Copy link
Contributor

Message from Meng Zhuo:

Patch Set 23:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Joel Sing:

Patch Set 22:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: 7a61508) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705996.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.
@gopherbot
Copy link
Contributor

Message from Xueqi Luo:

Patch Set 27:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Joel Sing:

Patch Set 27: Commit-Queue+1

(6 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 27:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2025-12-09T14:13:58Z","revision":"508280f1378d92be12d2466089e8f9904467054d"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Joel Sing:

Patch Set 27: -Commit-Queue


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 27:

This CL has passed the run


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go LUCI:

Patch Set 27: LUCI-TryBot-Result+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/705996.
After addressing review feedback, remember to publish your drafts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants