https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94734
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- + int cstore_31; + int cstore_32; <bb 2> [local count: 114863530]: goto <bb 7>; [100.00%] <bb 3> [local count: 1014686026]: _1 = (long unsigned int) sum_a_7; _2 = _1 * 8; _3 = input_21(D) + _2; _4 = *_3; if (_4 == 0B) goto <bb 15>; [5.50%] else goto <bb 4>; [94.50%] <bb 4> [local count: 958878296]: if (sum_a_7 <= 1) - goto <bb 5>; [28.10%] + goto <bb 6>; [28.10%] else - goto <bb 6>; [71.90%] + goto <bb 5>; [71.90%] - <bb 5> [local count: 269444804]: - arr[sum_a_7] = 1; + <bb 5> [local count: 689433492]: + cstore_32 = MEM <int[2]> [(void *)&arr][sum_a_7]; <bb 6> [local count: 958878296]: + # cstore_31 = PHI <1(4), cstore_32(5)> + MEM <int[2]> [(void *)&arr][sum_a_7] = cstore_31; sum_a_23 = sum_a_7 + 1; done by cselim looks just plain wrong, there is no dominating load from that memory, so even when the variable is an automatic variable, there is no guarantee it won't be out of bounds and thus crash already on the load, or just modify random unrelated memory.