elliottt edited PR #5097 from trevor/remove-branch-instructions
to main
:
As discussed in the 2022/10/19 meeting, this PR removes many of the branch and select instructions that used iflags, in favor if using
brz
/brnz
andselect
in their place. Additionally, it reworksselectif_spectre_guard
to take ani8
input instead of aniflags
input.For reference, the removed instructions are:
br_icmp
,brif
,brff
,trueif
,trueff
, andselectif
.
<!--Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
elliottt updated PR #5097 from trevor/remove-branch-instructions
to main
.
elliottt updated PR #5097 from trevor/remove-branch-instructions
to main
.
elliottt requested cfallin for a review on PR #5097.
elliottt has marked PR #5097 as ready for review.
abrown submitted PR review.
abrown submitted PR review.
abrown created PR review comment:
This is an example where more work _must_ be done by the CPU due to this change, right?
elliottt submitted PR review.
elliottt created PR review comment:
It looks like we already generate multiple comparisons on main. I adapted the example you pointed out to work on the x64 backend (removed uses of
trueff
) and ran it throughclif-util test
as aprecise-output
test:function %fflags(f32) { block200(v0: f32): v1 = f32const 0x34.0p0 v2 = ffcmp v0, v1 brff eq v2, block201 jump block400 block400: brff ord v2, block202 jump block401 block401: return block201: return block202: trap heap_oob }
We produce assembly that has one
ucomiss
for eachbrff
, not one comparison whose flags are reused between those instructions, so the changes on this branch shouldn't affect performance.pushq %rbp movq %rsp, %rbp block0: movl $1112539136, %r8d movd %r8d, %xmm5 ucomiss %xmm5, %xmm0 jp label2 jnz label2; j label1 block1: movq %rbp, %rsp popq %rbp ret block2: movl $1112539136, %esi movd %esi, %xmm9 ucomiss %xmm9, %xmm0 jnp label3; j label4 block3: ud2 heap_oob block4: movq %rbp, %rsp popq %rbp ret
For completeness, here's the assembly generated for that same example on this branch, adjusted for
brff
being removed:pushq %rbp movq %rsp, %rbp block0: movl $1112539136, %r8d movd %r8d, %xmm5 ucomiss %xmm5, %xmm0 jp label2 jnz label2; j label1 block1: jmp label5 block2: movl $1112539136, %esi movd %esi, %xmm9 ucomiss %xmm9, %xmm0 jnp label3; j label4 block3: ud2 heap_oob block4: jmp label5 block5: movq %rbp, %rsp popq %rbp ret
elliottt updated PR #5097 from trevor/remove-branch-instructions
to main
.
elliottt updated PR #5097 from trevor/remove-branch-instructions
to main
.
abrown submitted PR review.
abrown created PR review comment:
Ah, good to know!
cfallin submitted PR review.
elliottt merged PR #5097.
Last updated: Dec 23 2024 at 12:05 UTC