View previous topic :: View next topic |
Author |
Message |
eccerr0r Watchman

Joined: 01 Jul 2004 Posts: 9927 Location: almost Mile High in the USA
|
Posted: Mon Mar 10, 2025 4:04 pm Post subject: |
|
|
On another note, ultimately since we're doing popcount on constants, I'm doubly surprised gcc didn't optimize all these away to another constant since f(constant) = another constant (at least standard arithmetic operators it's smart enough to do)...
granted fibonacci(999999) or factorial(999999) do take a lot of iterations to run (if not using their closed form solutions) and the compiler would still need to do it, so there's probably some stuff best left for runtime ... else it'd need to know a lot of solutions to iterative functions. _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
 |
John R. Graham Administrator


Joined: 08 Mar 2005 Posts: 10747 Location: Somewhere over Atlanta, Georgia
|
Posted: Mon Mar 10, 2025 8:14 pm Post subject: |
|
|
Hu wrote: | You may like the related trick that value & (value - 1) is false when value is a power of 2, and true otherwise. | Yeah, that would follow, wouldn't it, because all powers of two only have a single one bit.
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
 |
John R. Graham Administrator


Joined: 08 Mar 2005 Posts: 10747 Location: Somewhere over Atlanta, Georgia
|
Posted: Mon Mar 10, 2025 8:18 pm Post subject: |
|
|
eccerr0r wrote: | On another note, ultimately since we're doing popcount on constants, I'm doubly surprised gcc didn't optimize all these away to another constant since f(constant) = another constant (at least standard arithmetic operators it's smart enough to do)... | At LTO time, you mean? I've seen a rule that says you can't optimize out of existence a function with global visibility. Certainly the compiler doesn't know how it might be used elsewhere.
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|