Skip to content

Conversation

@david-arm
Copy link

We can fold sequences like this:

testl w0, w0
jcc CC_E, label

into a single, new opcode

cbz w0, label

if the flags set by testl are only used by the jcc operation. Not only does this reduce the number of instructions, but it also has the benefit of not clobbering the flags. On AArch64 the branch offset range for cbz/cbnz is identical to b.cc so there is no penalty for using them.

We can fold sequences like this:

testl w0, w0
jcc CC_E, label

into a single, new opcode

cbz w0, label

if the flags set by testl are only used by the jcc operation.
Not only does this reduce the number of instructions, but it
also has the benefit of not clobbering the flags. On AArch64
the branch offset range for cbz/cbnz is identical to b.cc so
there is no penalty for using them.
@meta-codesync
Copy link

meta-codesync bot commented Nov 13, 2025

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D86971426. (Because this pull request was imported automatically, there will not be any future comments.)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants