-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIhelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors
Milestone
Description
public class C {
public int A(int i) {
i += 2;
i += 4;
return i;
}
public int B(int i) {
var j = i;
j += 2;
j += 4;
return j;
}
public int ConsumeA(int i) => A(i);
public int ConsumeB(int i) => B(i);
}According to @SingleAccretion, this is because Roslyn prefers to use the IL stack for locals instead of parameters.
So an optimization would make sense for this.
I would argue that there is a real-world case, as I have seen code where no new variable was created but the parameter was modified directly.
En3Tho
Metadata
Metadata
Assignees
Labels
area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIhelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors