From patchwork Wed May 28 20:32:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 353577 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 ABD39140093 for ; Thu, 29 May 2014 06:33:10 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=TAulrYbu7GlScsL3EOeppALdjujuIQApidhg0uIG6rPae9qDFS UfVWpldCb6azOowE/wa1FYSp+60uyTE5gy69log4oT5xgZLOGIZEK/AuxMQ577dr b5b2xYrRHH6rCJReGc3ksn314Eu7u2PvWtFQO5h+J1NQCdQolCcxTqQzc= 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:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=/QLVM/XSdGKa+TmxAH2Bx54fkuU=; b=ff8cKo3BEkLiUyjzBlUs 0jGWE+3dt7ou37yi6Itk7OGUekPoECGCyTX4Wt3V+USHwg4nlOFbL+0z1xAAIv6l /O6jh1/TFZOj+UfvlIe46fB2+ex4xrjae1wm1hFtsRLkZQJ++n/2Ce07foFpYimZ gZ4K7+CWND07A5UWYYt0WOM= Received: (qmail 5715 invoked by alias); 28 May 2014 20:33:03 -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 5704 invoked by uid 89); 28 May 2014 20:33:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, LOTS_OF_MONEY, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-wg0-f50.google.com Received: from mail-wg0-f50.google.com (HELO mail-wg0-f50.google.com) (74.125.82.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 28 May 2014 20:33:02 +0000 Received: by mail-wg0-f50.google.com with SMTP id x12so12050843wgg.9 for ; Wed, 28 May 2014 13:32:58 -0700 (PDT) X-Received: by 10.194.6.166 with SMTP id c6mr3071924wja.64.1401309178895; Wed, 28 May 2014 13:32:58 -0700 (PDT) Received: from localhost ([2.26.169.52]) by mx.google.com with ESMTPSA id hs8sm19648968wib.10.2014.05.28.13.32.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 May 2014 13:32:58 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, vmakarov@redhat.com, rdsandiford@googlemail.com Cc: vmakarov@redhat.com Subject: RFA: A couple of ira_get_dup_out_num fixes Date: Wed, 28 May 2014 21:32:57 +0100 Message-ID: <87tx89abk6.fsf@talisman.default> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 While working on patches to speed up the handling of constraints, I hit some behaviour in ira_get_dup_out_num that looked unintentional: - the check for output operands was part of the !ignored_p condition so would be skipped if the first alternative is disabled/excluded. - the first disabled/excluded alternative stops all following alternatives from being processed, since we get "stuck" in the first part of the "if" statement and never increment curr_alt. This seems to have some effect on the testsuite. E.g. at -O2 gcc.c-torture/compile/20071117-1.c has changes like: .LCFI2: movq %rsp, %rbx subq %rax, %rsp - leaq 15(%rsp), %rax - andq $-16, %rax - movq %rax, %rdi + leaq 15(%rsp), %rdi + andq $-16, %rdi call bar xorl %esi, %esi movq %rbx, %rsp There are also some cases where the change introduces a move though. E.g. gcc.c-torture/compat/struct-ic.c has: movabsq $4294967296, %rdx addq $8, %rsp .LCFI4: - andq %rdi, %rax + andq %rax, %rdi + movq %rdi, %rax orq %rdx, %rax ret .L9: But AFAICT the patch is what was originally intended. Tested on x86_64-linux-gnu. OK to install? Thanks, Richard gcc/ * ira.c (ira_get_dup_out_num): Check for output operands at the start of the loop. Handle cases where an included alternative follows an excluded one. Index: gcc/ira.c =================================================================== --- gcc/ira.c 2014-05-28 20:48:25.747321188 +0100 +++ gcc/ira.c 2014-05-28 21:31:22.769217059 +0100 @@ -1979,33 +1979,33 @@ ira_get_dup_out_num (int op_num, HARD_RE if (op_num < 0 || recog_data.n_alternatives == 0) return -1; - use_commut_op_p = false; + /* We should find duplications only for input operands. */ + if (recog_data.operand_type[op_num] != OP_IN) + return -1; str = recog_data.constraints[op_num]; + use_commut_op_p = false; for (;;) { #ifdef EXTRA_CONSTRAINT_STR op = recog_data.operand[op_num]; #endif - for (ignore_p = false, original = -1, curr_alt = 0;;) + for (curr_alt = 0, ignore_p = !TEST_HARD_REG_BIT (alts, curr_alt), + original = -1;;) { c = *str; if (c == '\0') break; - if (c == '#' || !TEST_HARD_REG_BIT (alts, curr_alt)) + if (c == '#') ignore_p = true; else if (c == ',') { curr_alt++; - ignore_p = false; + ignore_p = !TEST_HARD_REG_BIT (alts, curr_alt); } else if (! ignore_p) switch (c) { - /* We should find duplications only for input operands. */ - case '=': - case '+': - goto fail; case 'X': case 'p': case 'g':