Open
Description
using System;
class X
{
volatile int a;
public static int Main()
{
var x = new X();
x.a = 50;
x.a = 100;
if (x.a == x.a) return 100;
return -1;
}
}
currently generates:
G_M32182_IG01:
4883EC28 sub rsp, 40
G_M32182_IG02:
48B95852BB61F97F0000 mov rcx, 0x7FF961BB5258
E85DFA7F5F call CORINFO_HELP_NEWSFAST
C7400832000000 mov dword ptr [rax+8], 50
C7400864000000 mov dword ptr [rax+8], 100
B864000000 mov eax, 100
G_M32182_IG03:
4883C428 add rsp, 40
C3 ret
Folding the compare is unsafe in general.
See also the somewhat related #6280.
category:correctness
theme:basic-cq
skill-level:intermediate
cost:small