https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90267
Bug ID: 90267 Summary: [7.3 regression] wrong code generated wth -O2 as missing data dependence base on memory Product: gcc Version: 7.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: zhongyunde at huawei dot com Target Milestone: --- Created attachment 46254 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46254&action=edit a simple testcase test case attached, and we can see the code in line 42 clear the memory point with pstruDlTpcPara, so the value in the memory cross the line 42 is different. 39 TpcFingerNum[TpcIdex][0] = *(UINT32*)(void*)pstruDlTpcPara; 40 TpcFingerNum[TpcIdex][1] = pstruDlTpcPara->ucThreeSlotFngNum; 41 42 *(volatile UINT32*)(void*)pstruDlTpcPara = 0; 43 44 TpcFingerNum[TpcIdex][2] = *(UINT32*)(void*)pstruDlTpcPara; 45 TpcFingerNum[TpcIdex][3] = pstruDlTpcPara->ucThreeSlotFngNum; base on the gcc 7.3, in the dumpfile test.c.037t.fre1, we can see the value _6 get before the operator of clear the memory. So it miss the data dependence base on memory. (Generated by cmd:../../GCC/gcc-730/binary/bin/gcc test.c -dAp -S -O2 -g3 -fdump-tree-all) 37 _4 = MEM[(struct STRU_CCH_DLTPC_PARA *)&gastruDlTpcPara][_1].ucThreeSlotFngNum; 38 _6 = (unsigned int) _4; 39 TpcFingerNum[TpcIdex.0_2][1] = _6; 40 MEM[(volatile UINT32 *)pstruDlTpcPara_20] ={v} 0; 41 _8 = MEM[(UINT32 *)pstruDlTpcPara_20]; 42 TpcFingerNum[TpcIdex.0_2][2] = _8; 43 TpcFingerNum[TpcIdex.0_2][3] = _6;