Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
12d59539
Unverified
Commit
12d59539
authored
Oct 1, 2023
by
Hanicef
Browse files
Options
Downloads
Patches
Plain Diff
Avoid branch prediction slowdowns in R_PointOnSide
parent
a373d96d
No related branches found
No related tags found
2 merge requests
!2355
fix newer versions of mixerx
,
!2168
Avoid branch prediction slowdowns in R_PointOnSide
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/r_main.c
+5
-4
5 additions, 4 deletions
src/r_main.c
with
5 additions
and
4 deletions
src/r_main.c
+
5
−
4
View file @
12d59539
...
...
@@ -249,7 +249,7 @@ static void FlipCam2_OnChange(void)
//
// killough 5/2/98: reformatted
//
INT32
R_PointOnSide
(
fixed_t
x
,
fixed_t
y
,
node_t
*
node
)
INT32
R_PointOnSide
(
fixed_t
x
,
fixed_t
y
,
node_t
*
restrict
node
)
{
if
(
!
node
->
dx
)
return
x
<=
node
->
x
?
node
->
dy
>
0
:
node
->
dy
<
0
;
...
...
@@ -261,9 +261,10 @@ INT32 R_PointOnSide(fixed_t x, fixed_t y, node_t *node)
fixed_t
dy
=
(
y
>>
1
)
-
(
node
->
y
>>
1
);
// Try to quickly decide by looking at sign bits.
if
((
node
->
dy
^
node
->
dx
^
dx
^
dy
)
<
0
)
return
(
node
->
dy
^
dx
)
<
0
;
// (left is negative)
return
FixedMul
(
dy
,
node
->
dx
>>
FRACBITS
)
>=
FixedMul
(
node
->
dy
>>
FRACBITS
,
dx
);
// also use a mask to avoid branch prediction
INT32
mask
=
(
node
->
dy
^
node
->
dx
^
dx
^
dy
)
>>
31
;
return
(
mask
&
((
node
->
dy
^
dx
)
<
0
))
|
// (left is negative)
(
~
mask
&
(
FixedMul
(
dy
,
node
->
dx
>>
FRACBITS
)
>=
FixedMul
(
node
->
dy
>>
FRACBITS
,
dx
)));
}
// killough 5/2/98: reformatted
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment