Couldn't find any related issue and decided to file it:
unsafe void DeadStore1(int* array) { *array = 1; *array = 2; *array = 3; } void DeadStore2(ref int x) { x = 1; x = 2; x = 3; } void DeadStore3(int[] array) { if (0 < (uint)array.Length) { array[0] = 1; array[0] = 2; array[0] = 3; } }
Codegen:
; DeadStore1(long):this G_M36731_IG01: G_M36731_IG02: mov dword ptr [rdx], 1 mov dword ptr [rdx], 2 mov dword ptr [rdx], 3 G_M36731_IG03: ret ; Total bytes of code: 19 ; DeadStore2(byref):this G_M42680_IG01: G_M42680_IG02: mov dword ptr [rdx], 1 mov dword ptr [rdx], 2 mov dword ptr [rdx], 3 G_M42680_IG03: ret ; Total bytes of code: 19 ; DeadStore3(System.Int32[]):this G_M18892_IG01: G_M18892_IG02: mov eax, dword ptr [rdx+8] test eax, eax je SHORT G_M18892_IG04 G_M18892_IG03: ;; bbWeight=0.50 mov dword ptr [rdx+16], 1 mov dword ptr [rdx+16], 2 mov dword ptr [rdx+16], 3 G_M18892_IG04: ret ; Total bytes of code: 29
In none of these cases dead stores were eliminated.
Is it a known Value Numbering limitation?
Mono-LLVM:
00000000000b10 <Program_DeadStore1_int_>: b10: c7 06 03 00 00 00 mov DWORD PTR [rsi],0x3 b16: c3 ret 0000000000000b20 <Program_DeadStore2_int_>: b20: c7 06 03 00 00 00 mov DWORD PTR [rsi],0x3 b26: c3 ret 0000000000000b30 <Program_DeadStore3_int__>: b30: 83 7e 18 00 cmp DWORD PTR [rsi+0x18],0x0 b34: 74 07 je b3d <Program_DeadStore3_int__+0xd> b36: c7 46 20 03 00 00 00 mov DWORD PTR [rsi+0x20],0x3 b3d: c3 ret
category:cq
theme:optimization
skill-level:intermediate
cost:small
impact:small
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4