From patchwork Fri Apr 3 18:47:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 1266170 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=h3XiecYF; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48v87y1x6Hz9sQt for ; Sat, 4 Apr 2020 05:47:56 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AC688388A02E; Fri, 3 Apr 2020 18:47:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC688388A02E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1585939673; bh=bSu93vcNEDP+z7V56xJ5KXMHby9UHAKoRIsGOE/+iZ0=; h=Subject:To:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=h3XiecYFw2xuZh4kQyvbPWDHHstXwynC9KNgqOpEXKvNB0Wvwk8LaP0OQkQkmNb8J EWh/fwbcey2eFqZ2SxpDBQKFBI5YOUMKKFmZBY7TSlqb4FZUg7+w6anniywg3xzHxr riWRnMrRoEsTR2TO3Uf2qpkb8UgA2V0QgcG2vPLo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 51CA0388A029 for ; Fri, 3 Apr 2020 18:47:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 51CA0388A029 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-152-XTlwnDD8ONGcECsU-YJg-g-1; Fri, 03 Apr 2020 14:47:46 -0400 X-MC-Unique: XTlwnDD8ONGcECsU-YJg-g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D5A4107ACCA for ; Fri, 3 Apr 2020 18:47:45 +0000 (UTC) Received: from ovpn-113-250.phx2.redhat.com (ovpn-113-250.phx2.redhat.com [10.3.113.250]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50E1C18A85 for ; Fri, 3 Apr 2020 18:47:45 +0000 (UTC) Message-ID: Subject: [committed] Fix m32r target bug exposed by Jakub's cselib.c changes To: gcc-patches List Date: Fri, 03 Apr 2020 12:47:44 -0600 Organization: Red Hat User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-26.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jeff Law via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: law@redhat.com Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" va-arg-22.c started failing on the m32r target (-O1 only) after Jakub's recent cselib changes. The m32r port has this pattern: (define_insn "cpymemsi_internal" [(set (mem:BLK (match_operand:SI 0 "register_operand" "r")) ;; destination (mem:BLK (match_operand:SI 1 "register_operand" "r"))) ;; source (use (match_operand:SI 2 "m32r_block_immediate_operand" "J"));; # bytes to move (set (match_operand:SI 3 "register_operand" "=0") (plus:SI (minus (match_dup 2) (const_int 4)) (match_dup 0))) (set (match_operand:SI 4 "register_operand" "=1") (plus:SI (match_dup 1) (match_dup 2))) (clobber (match_scratch:SI 5 "=&r")) ;; temp1 (clobber (match_scratch:SI 6 "=&r"))] ;; temp2 Note how it updates operand0/operand3 and operand1/operand4. In simplest terms it adds the # bytes copied to each operand. When we output the assembly code for the pattern it has some smarts to avoid doing half-word and byte loads to handle residuals -- instead it loads a full word. That's all fine and good, except the loads occur with post-increment addressing so after we're done with the actual memory copies the source pointer can actually point 1, 2 or 3 bytes beyond where it should. To compound the problem we then incorrectly manually adjust the operand to account for residuals resulting in the source pointer pointing 2, 4 or 6 bytes past where it should. In va-arg-22.c, when compiled with -O1, it turns out we want to use the adjusted source pointer in a subsequent insn. AFAICT, cselib didn't discover the equivalence before, but does so now and with the bugs in the m32r port noted above the pointer has the wrong value and all hell breaks loose. This patch fixes the assembly code we generate for cpymemsi_internal. Naturally this fixes va-arg-22.c at -O1. It doesn't fix any of the other long standing failures though. Committing to the trunk, Jeff commit b949f8e2acb49273b2f08ecaa3bc7128baaad850 Author: Jeff Law Date: Fri Apr 3 12:46:13 2020 -0600 Fix va-arg-22.c at -O1 on m32r. PR rtl-optimization/92264 * config/m32r/m32r.c (m32r_output_block_move): Properly account for post-increment addressing of source operands as well as residuals when computing any adjustments to the input pointer. diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7083bbb9cce..e9dfa71ec0e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2020-04-03 Jeff Law + + PR rtl-optimization/92264 + * config/m32r/m32r.c (m32r_output_block_move): Properly account for + post-increment addressing of source operands as well as residuals + when computing any adjustments to the input pointer. + 2020-04-03 Jakub Jelinek PR target/94460 diff --git a/gcc/config/m32r/m32r.c b/gcc/config/m32r/m32r.c index 1c015609524..27fb495ed17 100644 --- a/gcc/config/m32r/m32r.c +++ b/gcc/config/m32r/m32r.c @@ -2676,7 +2676,7 @@ m32r_output_block_move (rtx insn ATTRIBUTE_UNUSED, rtx operands[]) destination pointer. */ int dst_inc_amount = dst_offset + bytes - 4; /* The same for the source pointer. */ - int src_inc_amount = bytes; + int src_inc_amount = bytes - (got_extra ? 4 : 0); int last_shift; rtx my_operands[3];