From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 89438 invoked by alias); 22 Sep 2015 01:57:46 -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 88468 invoked by uid 48); 22 Sep 2015 01:57:41 -0000 From: "olegendo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/67675] [SH] Improve __builtin_strcmp alignment test Date: Tue, 22 Sep 2015 01:57: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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: olegendo at gcc dot gnu.org 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: bug_status cf_reconfirmed_on everconfirmed 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-09/txt/msg01743.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67675 Oleg Endo changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2015-09-22 Ever confirmed|0 |1 --- Comment #1 from Oleg Endo --- This fixes it: Index: gcc/config/sh/sh-mem.cc =================================================================== --- gcc/config/sh/sh-mem.cc (revision 227970) +++ gcc/config/sh/sh-mem.cc (working copy) @@ -224,11 +224,10 @@ rtx_code_label *L_loop_long = gen_label_rtx (); rtx_code_label *L_end_loop_long = gen_label_rtx (); - int align = INTVAL (operands[3]); + const unsigned int addr1_alignment = MEM_ALIGN (operands[1]) / BITS_PER_UNIT; + const unsigned int addr2_alignment = MEM_ALIGN (operands[2]) / BITS_PER_UNIT; - emit_move_insn (tmp0, const0_rtx); - - if (align < 4) + if (addr1_alignment < 4 && addr2_alignment < 4) { emit_insn (gen_iorsi3 (tmp1, s1_addr, s2_addr)); emit_insn (gen_tstsi_t (tmp1, GEN_INT (3))); @@ -235,6 +234,18 @@ jump = emit_jump_insn (gen_branch_false (L_loop_byte)); add_int_reg_note (jump, REG_BR_PROB, prob_likely); } + else if (addr1_alignment < 4 && addr2_alignment >= 4) + { + emit_insn (gen_tstsi_t (s1_addr, GEN_INT (3))); + jump = emit_jump_insn (gen_branch_false (L_loop_byte)); + add_int_reg_note (jump, REG_BR_PROB, prob_likely); + } + else if (addr1_alignment >= 4 && addr2_alignment < 4) + { + emit_insn (gen_tstsi_t (s2_addr, GEN_INT (3))); + jump = emit_jump_insn (gen_branch_false (L_loop_byte)); + add_int_reg_note (jump, REG_BR_PROB, prob_likely); + } addr1 = adjust_automodify_address (addr1, SImode, s1_addr, 0); addr2 = adjust_automodify_address (addr2, SImode, s2_addr, 0);