Hacker Times
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
tredre3
18 days ago
|
parent
|
context
|
favorite
| on:
Your code is fast if you're lucky
The ternary isn't guaranteed to be branchless. In your case it should almost always be on a modern compiler, but it really shouldn't be present in what one would call branchless code.
xyzsparetimexyz
18 days ago
|
next
[–]
Does any standard library have a glsl-like select(condition, true_val, false_val) that is more or less guaranteed to correspond to a csel?
misev
18 days ago
|
prev
[–]
You could rewrite it to
int* ptr = ((v != 0) * lwr) + ((v == 0) * rwr);
I doubt it would be faster than the ternary though.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: