From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8993 invoked by alias); 21 Nov 2012 09:17:41 -0000 Received: (qmail 6809 invoked by uid 48); 21 Nov 2012 09:15:40 -0000 From: "amker.cheng at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/55424] New: [4.8 Regression]gcc.dg/uninit-pred-8_b.c bogus warning line 23 on ARM/Cortex-M0/-Os Date: Wed, 21 Nov 2012 09:17:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: amker.cheng at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-11/txt/msg02013.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55424 Bug #: 55424 Summary: [4.8 Regression]gcc.dg/uninit-pred-8_b.c bogus warning line 23 on ARM/Cortex-M0/-Os Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: tree-optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: amker.cheng@gmail.com The test case require optimization level "-O2" and it passes on ARM/cortex-m0 with "-O2", but the failure with "-Os" does reveal potential bug in tree-ssa-uninit.c Test command line: arm-none-eabi-gcc ./uninit-pred-8_b.c -fno-diagnostics-show-caret -Wuninitialized -fno-tree-dominator-opts -S -mthumb -mcpu=cortex-m0 -Os -o uninit-pred-8_b.s The warning info: .../trunk-orig/gcc/gcc/testsuite/gcc.dg/uninit-pred-8_b.c: In function 'foo': .../trunk-orig/gcc/gcc/testsuite/gcc.dg/uninit-pred-8_b.c:23:11: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized] .../trunk-orig/gcc/gcc/testsuite/gcc.dg/uninit-pred-8_b.c: In function 'foo_2': .../trunk-orig/gcc/gcc/testsuite/gcc.dg/uninit-pred-8_b.c:42:11: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized] This failure occurs after checking in r193687. The patch prefers to generate branches on ARM/cortex-m0. After investigating tree dump of tree-ssa-uninit.c, I think: tree-ssa-uninit.c computes control dependent chain for uses/def of variable and checks whether each use is guarded by def. It has a upper bound on the number of control dependent chains(MAX_NUM_CHAINS==8) and just retreat to false warning if the number of chains exceeds MAX_NUM_CHAINS. In our scenario, the number of chains exceeds MAX_NUM_CHAINS because we prefer short circuit now, resulting in false warning information. These false warning cannot be fully removed if the MAX_NUM_CHAINS exists, but we can improve it in following way: There are lots of invalid control dependent chains computed in tree-ssa-uninit.c now and should be pruned. I have already implemented a quick fix and it works for our scenario. I am not sure it should be fixed in this way, so please comments if you have any opinions. Thanks Dump of tree-ssa-uninit.c: ;; Function foo (foo, funcdef_no=0, decl_uid=4065, cgraph_uid=0) Use in stmt v_24 = PHI is guarded by : (.NOT.) if (m_6(D) != 0) Operand defs of phi v_1 = PHI is guarded by : (.NOT.) if (n_5(D) <= 9) (.AND.) (.NOT.) if (m_6(D) > 100) (.AND.) if (r_7(D) <= 19) (.OR.) if (n_5(D) <= 9) (.OR.) (.NOT.) if (n_5(D) <= 9) (.AND.) (.NOT.) if (m_6(D) > 100) (.AND.) (.NOT.) if (r_7(D) <= 19) (.AND.) if (l_8(D) != 0) foo (int n, int l, int m, int r) { int v; int g.1; int g.0; : if (n_5(D) <= 9) goto ; else goto ; : if (m_6(D) > 100) goto ; else goto ; : if (r_7(D) <= 19) goto ; else goto ; : if (l_8(D) != 0) goto ; else goto ; : : # v_1 = PHI if (m_6(D) != 0) goto ; else goto ; : # v_25 = PHI g.0_11 = g; g.1_12 = g.0_11 + 1; g = g.1_12; goto ; : bar (); : # v_24 = PHI if (n_5(D) <= 9) goto ; else goto ; : if (m_6(D) > 100) goto ; else goto ; : if (r_7(D) <= 19) goto ; else goto ; : if (m_6(D) > 100) goto ; else goto ; : blah (v_24); if (n_5(D) <= 9) goto ; else goto ; : blah (v_24); goto ; : if (r_7(D) <= 9) goto ; else goto ; : return 0; : # v_22 = PHI goto ; }