Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not only is LEA more flexible I believe it's preferred to SHL even for simple operations because it doesn't modify the flags register which can make it easier to schedule.


It's more about the non-destructive destination part, which can avoid a move. Compilers tend to prefer SHL/SAL of LEA because its encoding is shorter: https://godbolt.org/z/9Tsq3hKnY


shlx doesn't alter the flag register.


SHLX does not support an immediate operand. Non-destructive shifts with immediate operands only arrive with APX, where they are among the most commonly used instructions (besides paired pushes/pops).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: