From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A667A3857022; Tue, 1 Dec 2020 03:03:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A667A3857022 From: "admin at levyhsu dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/97417] RISC-V Unnecessary andi instruction when loading volatile bool Date: Tue, 01 Dec 2020 03:03:47 +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: 10.2.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: admin at levyhsu dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: 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: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Dec 2020 03:03:47 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97417 --- Comment #46 from Levy --- Looking at gcc/passed.def and gcc/config/riscv-passes.def: pass_shorten_memrefs is inserted after NEXT_PASS (pass_rtl_store_motion); NEXT_PASS (pass_rtl_store_motion); (pass_shorten_memrefs) NEXT_PASS (pass_cse_after_global_opts); NEXT_PASS (pass_rtl_ifcvt); NEXT_PASS (pass_reginfo_init); /* Perform loop optimizations. It might be better to do them a bit sooner, but we want the profile feedback to work more efficiently. */ NEXT_PASS (pass_loop2); PUSH_INSERT_PASSES_WITHIN (pass_loop2) NEXT_PASS (pass_rtl_loop_init); NEXT_PASS (pass_rtl_move_loop_invariants); NEXT_PASS (pass_rtl_unroll_loops); NEXT_PASS (pass_rtl_doloop); NEXT_PASS (pass_rtl_loop_done); POP_INSERT_PASSES () NEXT_PASS (pass_lower_subreg2); NEXT_PASS (pass_web); NEXT_PASS (pass_rtl_cprop); NEXT_PASS (pass_cse2); NEXT_PASS (pass_rtl_dse1); NEXT_PASS (pass_rtl_fwprop_addr); NEXT_PASS (pass_inc_dec); NEXT_PASS (pass_initialize_regs); NEXT_PASS (pass_ud_rtl_dce); NEXT_PASS (pass_combine); NEXT_PASS (pass_if_after_combine); NEXT_PASS (pass_jump_after_combine); NEXT_PASS (pass_partition_blocks); NEXT_PASS (pass_outof_cfg_layout_mode); NEXT_PASS (pass_split_all_insns); NEXT_PASS (pass_lower_subreg3); NEXT_PASS (pass_df_initialize_no_opt); NEXT_PASS (pass_stack_ptr_mod); NEXT_PASS (pass_mode_switching); NEXT_PASS (pass_match_asm_constraints); NEXT_PASS (pass_sms); NEXT_PASS (pass_live_range_shrinkage); NEXT_PASS (pass_sched); NEXT_PASS (pass_early_remat); NEXT_PASS (pass_ira); NEXT_PASS (pass_reload); NEXT_PASS (pass_postreload); PUSH_INSERT_PASSES_WITHIN (pass_postreload) NEXT_PASS (pass_postreload_cse); NEXT_PASS (pass_gcse2); NEXT_PASS (pass_split_after_reload); ...... After some debugging processes. it seems either: 1.The address cost info was calculated between (pass_combine) and (pass_shorten_memrefs) for patched version, then merged in the combined pas= s.=20 patched one is failed to be recognized as unpathed one due to Sign/Zero ext= end then Subreg. This can be verified by adding -fdisable-rtl-combine option when compile, a= lso the address_cost was not called for the whole time. 2.4 insn was determined(or say fixed?) before (pass_rtl_fwprop_addr), as for patched version, I saw forward_propagate_and_simplify() was called for 4 ex= tra times, then pass all the way to propagate_rtx()->propagate_rtx_1()->should_replace_address()->address_cost(= ) in fwprop.c I've also tested the (pass_postreload) as mentioned by Jim and new_address_profitable_p(). But they seem not to be the right one. Need some time to examine and trace the pass between (pass_shorten_memrefs)= and (pass_rtl_fwprop_addr).=