You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JIT sometimes emits unnecessary movsxd instructions when performing logical operations against consts #32089
The Roslyn behavior makes sense to me, so I don't think an analyzer is needed. What this issue tracks is that I was hoping the JIT could recognize that the sign-extension was throwaway work (since the comparison is against a constant) and that it could avoid emitting the instruction.
You can also see this with other types like byte and short, not just int:
publicstaticboolFoo(bytei){return(i&0x20)==0;}
; C.Foo(Byte) L0000: movzxeax,cl ; <-- not needed L0003: testal,0x20 L0005: setz al L0008: movzxeax,al L000b: ret
This is fairly endemic; the jit does not do the analysis to determine when entire trees of computation can be safely and more profitably done on a smaller (or sometimes, larger) type.
Activity
GrabYourPitchforks commentedon Feb 11, 2020
The Roslyn behavior makes sense to me, so I don't think an analyzer is needed. What this issue tracks is that I was hoping the JIT could recognize that the sign-extension was throwaway work (since the comparison is against a constant) and that it could avoid emitting the instruction.
You can also see this with other types like
byteandshort, not justint:AndyAyersMS commentedon Feb 11, 2020
This is fairly endemic; the jit does not do the analysis to determine when entire trees of computation can be safely and more profitably done on a smaller (or sometimes, larger) type.
AndyAyersMS commentedon Feb 13, 2020
I can't find any overall issue talking about narrowing/widening -- @dotnet/jit-contrib anyone know of one?
BruceForstall commentedon Oct 30, 2022
Going to close this in favor of #32504