From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22168 invoked by alias); 8 Jan 2015 13:55:57 -0000 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 Received: (qmail 22120 invoked by uid 48); 8 Jan 2015 13:55:52 -0000 From: "vries at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/64154] enable fipa-ra for Thumb1 Date: Thu, 08 Jan 2015 13:55:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-01/txt/msg00463.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64154 --- Comment #3 from vries at gcc dot gnu.org --- (In reply to Terry Guo from comment #2) > Hi Tom, > > I enabled this optimization to thumb1 target cortex-m0 Does that mean you just reverted the patch for PR63718? > and found this IPA-RA > optimization doesn't consider the register clobber information attached to > call rtx The IPA-RA analysis does consider that clobber. It's using find_all_hard_reg_sets, and that function contains a loop over CALL_INSN_FUNCTION_USAGE. > and thus generated bad code. Here are the bad rtxs I extracted from > the dump of cprop_hardreg pass: > > (insn 292 291 141 13 (set (reg:SI 4 r4 [orig:163 ivtmp.108 ] [163]) > (reg:SI 12 ip [orig:163 ivtmp.108 ] [163])) 742 {*thumb1_movsi_insn} > (expr_list:REG_DEAD (reg:SI 12 ip [orig:163 ivtmp.108 ] [163]) > (nil))) > > (call_insn 141 292 142 13 (parallel [ > (call (mem:SI (symbol_ref:SI ("f2") [flags 0x3] 0x7f8182689100 f2>) [0 f2 S4 A32]) > (const_int 0 [0])) > (use (const_int 0 [0])) > (clobber (reg:SI 14 lr)) > ]) > /myssd/terguo01/toolchain-build/GCC32RM-424/src/gcc/gcc/testsuite/gcc.dg/ > vshift-3.c:119 770 {*call_insn} > (expr_list:REG_CALL_DECL (symbol_ref:SI ("f2") [flags 0x3] > ) > (expr_list:REG_EH_REGION (const_int 0 [0]) > (nil))) > (expr_list (clobber (reg:SI 12 ip)) > (nil))) > > (insn 11 10 12 13 (set (reg:SI 0 r0 [orig:170 ivtmp.130 ] [170]) > (reg:SI 12 ip [orig:163 ivtmp.108 ] [163])) > /myssd/terguo01/toolchain-build/GCC32RM-424/src/gcc/gcc/testsuite/gcc.dg/ > vshift-3.c:121 742 {*thumb1_movsi_insn} > (expr_list:REG_EQUAL (symbol_ref:SI ("j") [flags 0x80] 0x7f81827d0750 j>) > (nil))) > That is wrong indeed: ip is explicitly clobbered by the call in CALL_INSN_FUNCTION_USAGE, but used as if not clobbered by the call. > I checked the code in 'if (CALL_P (insn))' part in file regcprop.c and found > the algorithm doesn't consider the '(expr_list (clobber (reg:SI 12 ip))' in > insn 141 which makes current algorithm think it is safe to propagate ip from > insn 292 to insn 11. > I cannot reproduce the wrong code as listed above. But I can reproduce the clobber being skipped by copyprop_hardreg_forward_1. So I agree, cprop_hardreg does not respect the clobber on the call in CALL_INSN_FUNCTION_USAGE. I'll file a PR.