Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shifting versus Mutliplying
#6
Exactly what @a740g said. It seems the likely issue you're seeing is that because no optimization is applied to the generated source (unless you enable it in the `Compiler Settings`), the `_shl` function is not inlined by the compiler, that makes it significantly slower than the `* 4` which is just turned into a single shift instruction. You can see it in the disassembly, the first highlighted line is the shift generated for the `y = x * 4`, the second highlighted line is the call to the `_SHL` function when doing `_SHL(x, 2)`.


[Image: shift.png]
Reply


Messages In This Thread
Shifting versus Mutliplying - by TerryRitchie - 03-11-2024, 03:36 AM
RE: Shifting versus Mutliplying - by DSMan195276 - 03-11-2024, 03:57 AM
RE: Shifting versus Mutliplying - by TerryRitchie - 03-11-2024, 04:19 AM
RE: Shifting versus Mutliplying - by TerryRitchie - 03-11-2024, 04:34 AM
RE: Shifting versus Mutliplying - by a740g - 03-11-2024, 05:16 AM
RE: Shifting versus Mutliplying - by DSMan195276 - 03-11-2024, 06:21 AM
RE: Shifting versus Mutliplying - by Kernelpanic - 03-11-2024, 12:28 PM
RE: Shifting versus Mutliplying - by mcalkins - 05-05-2024, 11:51 PM



Users browsing this thread: 4 Guest(s)