From patchwork Fri Oct 30 17:48:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 538459 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4E55C140787 for ; Sat, 31 Oct 2015 04:49:03 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=CLk82qlX; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=AyJuM2430VMDnKFnLPKpOwgQ4sKbDWMs1i5do9lelbCwwgVoPZ ri61LBi0drJPeGqa4MfbSOQbd9957tNca4xfRN8ksLoTCuSe4oxz4IZgjXC9Z4Kq +S17pj9XLKSjsAXG5YPXOWMLUXB/8VtPUaL2DEuJsdXW8jlFXDIc6QdMo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=66sdNwQ1kl2WBH3VSFQ5uHvk9Dc=; b=CLk82qlXdu3o2HkPc6xp ADNZVo/eGuruE2teCQcFdbEiAt1xu4PkJhBWH8JbaAnGU9eSHOumLHvGtUp3MP5d 42EQXwsb0yDb3e0mSxuAG5/QlWQkZOrLkm+TQS1vPF6hYWLX4tqPiJ81R8IBOprJ 48WIf91WYwl//71OUIHOlng= Received: (qmail 110468 invoked by alias); 30 Oct 2015 17:48:54 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 110457 invoked by uid 89); 30 Oct 2015 17:48:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 30 Oct 2015 17:48:52 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 26915ABBBC for ; Fri, 30 Oct 2015 17:48:51 +0000 (UTC) Received: from [10.3.112.91] (ovpn-112-91.phx2.redhat.com [10.3.112.91]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9UHmnMH013558 for ; Fri, 30 Oct 2015 13:48:50 -0400 To: gcc-patches From: Vladimir Makarov Subject: patch to fix PR68106 Message-ID: <5633AD81.2080800@redhat.com> Date: Fri, 30 Oct 2015 13:48:49 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 X-IsSubscribed: yes The following patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68106 The patch was bootstrapped and tested on x86/x86-64 and tested on aarch64. Committed as rev. 229593. Index: ChangeLog =================================================================== --- ChangeLog (revision 229592) +++ ChangeLog (working copy) @@ -1,3 +1,12 @@ +2015-10-30 Vladimir Makarov + + PR rtl-optimization/68106 + * lra-remat.c (input_regno_present_p): Process hard regs + explicitly present in machine description insns. + (call_used_input_regno_present_p): Ditto. + (calculate_gen_cands): Ditto. + (do_remat): Ditto. + 2015-10-30 Jim Wilson * config/arm/neon-testgen.ml: Fix comment typo. Index: lra-remat.c =================================================================== --- lra-remat.c (revision 229592) +++ lra-remat.c (working copy) @@ -695,12 +695,17 @@ calculate_local_reg_remat_bb_data (void) static bool input_regno_present_p (rtx_insn *insn, int regno) { + int iter; lra_insn_recog_data_t id = lra_get_insn_recog_data (insn); + struct lra_static_insn_data *static_id = id->insn_static_data; struct lra_insn_reg *reg; - - for (reg = id->regs; reg != NULL; reg = reg->next) - if (reg->type == OP_IN && reg->regno == regno) - return true; + + for (iter = 0; iter < 2; iter++) + for (reg = (iter == 0 ? id->regs : static_id->hard_regs); + reg != NULL; + reg = reg->next) + if (reg->type == OP_IN && reg->regno == regno) + return true; return false; } @@ -708,13 +713,18 @@ input_regno_present_p (rtx_insn *insn, i static bool call_used_input_regno_present_p (rtx_insn *insn) { + int iter; lra_insn_recog_data_t id = lra_get_insn_recog_data (insn); + struct lra_static_insn_data *static_id = id->insn_static_data; struct lra_insn_reg *reg; - for (reg = id->regs; reg != NULL; reg = reg->next) - if (reg->type == OP_IN && reg->regno <= FIRST_PSEUDO_REGISTER - && TEST_HARD_REG_BIT (call_used_reg_set, reg->regno)) - return true; + for (iter = 0; iter < 2; iter++) + for (reg = (iter == 0 ? id->regs : static_id->hard_regs); + reg != NULL; + reg = reg->next) + if (reg->type == OP_IN && reg->regno <= FIRST_PSEUDO_REGISTER + && TEST_HARD_REG_BIT (call_used_reg_set, reg->regno)) + return true; return false; } @@ -761,11 +771,13 @@ calculate_gen_cands (void) if (INSN_P (insn)) { lra_insn_recog_data_t id = lra_get_insn_recog_data (insn); + struct lra_static_insn_data *static_id = id->insn_static_data; struct lra_insn_reg *reg; unsigned int uid; bitmap_iterator bi; cand_t cand; rtx set; + int iter; int src_regno = -1, dst_regno = -1; if ((set = single_set (insn)) != NULL @@ -777,26 +789,29 @@ calculate_gen_cands (void) /* Update gen_cands: */ bitmap_clear (&temp_bitmap); - for (reg = id->regs; reg != NULL; reg = reg->next) - if (reg->type != OP_IN - || find_regno_note (insn, REG_DEAD, reg->regno) != NULL) - EXECUTE_IF_SET_IN_BITMAP (&gen_insns, 0, uid, bi) - { - rtx_insn *insn2 = lra_insn_recog_data[uid]->insn; - - cand = insn_to_cand[INSN_UID (insn2)]; - gcc_assert (cand != NULL); - /* Ignore the reload insn. */ - if (src_regno == cand->reload_regno - && dst_regno == cand->regno) - continue; - if (cand->regno == reg->regno - || input_regno_present_p (insn2, reg->regno)) - { - bitmap_clear_bit (gen_cands, cand->index); - bitmap_set_bit (&temp_bitmap, uid); - } - } + for (iter = 0; iter < 2; iter++) + for (reg = (iter == 0 ? id->regs : static_id->hard_regs); + reg != NULL; + reg = reg->next) + if (reg->type != OP_IN + || find_regno_note (insn, REG_DEAD, reg->regno) != NULL) + EXECUTE_IF_SET_IN_BITMAP (&gen_insns, 0, uid, bi) + { + rtx_insn *insn2 = lra_insn_recog_data[uid]->insn; + + cand = insn_to_cand[INSN_UID (insn2)]; + gcc_assert (cand != NULL); + /* Ignore the reload insn. */ + if (src_regno == cand->reload_regno + && dst_regno == cand->regno) + continue; + if (cand->regno == reg->regno + || input_regno_present_p (insn2, reg->regno)) + { + bitmap_clear_bit (gen_cands, cand->index); + bitmap_set_bit (&temp_bitmap, uid); + } + } if (CALL_P (insn)) EXECUTE_IF_SET_IN_BITMAP (&gen_insns, 0, uid, bi) @@ -1070,6 +1085,7 @@ do_remat (void) unsigned int cid; bitmap_iterator bi; rtx set; + int iter; int src_regno = -1, dst_regno = -1; if ((set = single_set (insn)) != NULL @@ -1155,21 +1171,24 @@ do_remat (void) bitmap_clear (&temp_bitmap); /* Update avail_cands (see analogous code for calculate_gen_cands). */ - for (reg = id->regs; reg != NULL; reg = reg->next) - if (reg->type != OP_IN - || find_regno_note (insn, REG_DEAD, reg->regno) != NULL) - EXECUTE_IF_SET_IN_BITMAP (&avail_cands, 0, cid, bi) - { - cand = all_cands[cid]; - - /* Ignore the reload insn. */ - if (src_regno == cand->reload_regno - && dst_regno == cand->regno) - continue; - if (cand->regno == reg->regno - || input_regno_present_p (cand->insn, reg->regno)) - bitmap_set_bit (&temp_bitmap, cand->index); - } + for (iter = 0; iter < 2; iter++) + for (reg = (iter == 0 ? id->regs : static_id->hard_regs); + reg != NULL; + reg = reg->next) + if (reg->type != OP_IN + || find_regno_note (insn, REG_DEAD, reg->regno) != NULL) + EXECUTE_IF_SET_IN_BITMAP (&avail_cands, 0, cid, bi) + { + cand = all_cands[cid]; + + /* Ignore the reload insn. */ + if (src_regno == cand->reload_regno + && dst_regno == cand->regno) + continue; + if (cand->regno == reg->regno + || input_regno_present_p (cand->insn, reg->regno)) + bitmap_set_bit (&temp_bitmap, cand->index); + } if (CALL_P (insn)) EXECUTE_IF_SET_IN_BITMAP (&avail_cands, 0, cid, bi) Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 229592) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2015-10-30 Vladimir Makarov + + PR rtl-optimization/68106 + * testsuite/gcc.target/aarch64/pr68106.c: New. + 2015-10-30 Steven G. Kargl PR fortran/36192 Index: testsuite/gcc.target/aarch64/pr68106.c =================================================================== --- testsuite/gcc.target/aarch64/pr68106.c (revision 0) +++ testsuite/gcc.target/aarch64/pr68106.c (working copy) @@ -0,0 +1,50 @@ +/* { dg-do run { target aarch64*-*-* } } */ +/* { dg-options "-O" } */ + +typedef signed long long int S; +typedef unsigned long long int U; +typedef __int128 W; +__attribute__ ((noinline, noclone)) +U upseu (U x, S y, int *ovf) +{ + U res; + *ovf = __builtin_add_overflow (x, y, &res); + return res; +} +U +usueu (U x, U y, int *ovf) +{ + U res; + *ovf = __builtin_sub_overflow (x, y, &res); + return res; +} +U +usseu (U x, S y, int *ovf) +{ + U res; + *ovf = __builtin_sub_overflow (x, y, &res); + return res; +} +int +main () +{ + int i, j; + for (i = 0; i < ((unsigned char) ~0); i++) + for (j = 0; j < ((unsigned char) ~0); j++) + { + U u1 = ((W) i << ((8 - 1) * 8)); + S s2 = ((W) j << ((8 - 1) * 8)) + (-0x7fffffffffffffffLL - 1); + U u2 = ((W) j << ((8 - 1) * 8)); + W w; + int ovf; + w = ((W) u1) + ((W) s2); + if (upseu (u1, s2, &ovf) != (U) w || ovf != (w != (U) w)) + __builtin_abort (); + w = ((W) u1) - ((W) u2); + if (usueu (u1, u2, &ovf) != (U) w || ovf != (w != (U) w)) + __builtin_abort (); + w = ((W) u1) - ((W) s2); + if (usseu (u1, s2, &ovf) != (U) w || ovf != (w != (U) w)) + __builtin_abort (); + } +}