From patchwork Thu Oct 11 21:09:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Koning X-Patchwork-Id: 982739 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-487397-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=comcast.net Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="X7U8/tEJ"; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=comcast.net header.i=@comcast.net header.b="cwKEHPmV"; dkim-atps=neutral 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 42WNrB5M6qz9s8J for ; Fri, 12 Oct 2018 08:09:14 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :content-type:content-transfer-encoding:mime-version:subject :message-id:date:to; q=dns; s=default; b=TIWkWU8BbA2gqaiSch30r4T codmtB23BaHaYbNVGMGn42zHIrYaOcwOlEwBvsTZQzMxQIewhbPT0AdUM2U0ynKR FD5NHhdVT60gUI2FBh72/b+XU+Y9h5hocOrOoGv/AfFzWdqyS4Ctklff4vQW09t4 hmUDDeLWJcJ2E+TgnL/I= 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 :content-type:content-transfer-encoding:mime-version:subject :message-id:date:to; s=default; bh=m8F+9pnjws3zr9N6HcvRCu/r7WA=; b= X7U8/tEJTCkFSAeFHlClXQmL2vMTHL20c/WAKQtnNPGy9P5VES5QS5BtNU5CEg2y ANvV6kTQNGHpZwwduEP06U6v+t1qt0v4BWlgflNCfH2EkM6uEvfd0QZkvUJG3P2M btuFDiCZJddNwuzdp+/6ezIV6/rtCVLb39VFlNEsHwc= Received: (qmail 5602 invoked by alias); 11 Oct 2018 21:09:06 -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 5590 invoked by uid 89); 11 Oct 2018 21:09:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: resqmta-po-01v.sys.comcast.net Received: from resqmta-po-01v.sys.comcast.net (HELO resqmta-po-01v.sys.comcast.net) (96.114.154.160) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 11 Oct 2018 21:09:04 +0000 Received: from resomta-po-05v.sys.comcast.net ([96.114.154.229]) by resqmta-po-01v.sys.comcast.net with ESMTP id Ac9egO3pk5Cv3AiCcg9Ldg; Thu, 11 Oct 2018 21:09:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20161114; t=1539292142; bh=9pe+pri96uvlZ8ndI1q3Qv2DXOOHhonlCN2mNHLXZlo=; h=Received:Received:From:Content-Type:Mime-Version:Subject: Message-Id:Date:To; b=cwKEHPmVqaSGVtGmXWnCMUycdNiysC//r6ITg5NFkc5JroTca/scVbTmBQGcM4FFY NWm/J8KWy3+C1jSR9x3OJ01Q/I+O1Z8zzCMUm+gJw+DHrvIWMOywq/Kfqlhcwkonkq nu75zkV843ZgQQj+A1kflz4F2gwJEmpXi3BjuJz+iFglCB6jOBNCZp332Ie4tyYbVt J+vJj7NzURmo7Ynf8Zx1/rfgZ0ZRNusKiv4YBepDtIuMxtvTqxlRnnMzZurx2v3yL7 KYoWflbIPBQQV7eLDUpC8JUrAsf+Jnhum5DOjb8SCv9ruzLmsfp/oIjx8bLxkM93e1 UOICWmOC0wqmA== Received: from [192.168.10.125] ([73.60.223.101]) by resomta-po-05v.sys.comcast.net with ESMTPSA id AiCbgJjpvfffuAiCcgeYxQ; Thu, 11 Oct 2018 21:09:02 +0000 From: Paul Koning Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: [PATCH, doc] describe mode checking for doloop_end pattern Message-Id: Date: Thu, 11 Oct 2018 17:09:01 -0400 To: GCC patches Updated with an additional item I just debugged. Since the code that uses the doloop_end pattern does not check the operand mode as given in the pattern, the pattern itself may need to do this, and that was not documented. In addition, if the doloop_end pattern is a define_expand, there must be a define_insn (or define_insn_and_split) matching the generated pattern. I had a define_split instead, and the result was an ICE in loop optimization (loop2_done pass). This patch adds that information. It also updates the example to reflect this. Ok for trunk? paul ChangeLog: 2018-10-11 Paul Koning * doc/md.texi (doloop_end): Document that the pattern code may need to check operand mode. Index: md.texi =================================================================== --- md.texi (revision 265042) +++ md.texi (working copy) @@ -7619,7 +7619,23 @@ simplified) from the PDP-11 target: @smallexample @group -(define_insn "doloop_end" +(define_expand "doloop_end" + [(parallel [(set (pc) + (if_then_else + (ne (match_operand:HI 0 "nonimmediate_operand" "+r,!m") + (const_int 1)) + (label_ref (match_operand 1 "" "")) + (pc))) + (set (match_dup 0) + (plus:HI (match_dup 0) + (const_int -1)))])] + "" + "@{ + if (GET_MODE (operands[0]) != HImode) + FAIL; + @}") + +(define_insn "doloop_end_insn" [(set (pc) (if_then_else (ne (match_operand:HI 0 "nonimmediate_operand" "+r,!m") @@ -7662,10 +7678,23 @@ will be non-negative. Since the @code{doloop_end} insn is a jump insn that also has an output, the reload pass does not handle the output operand. Therefore, the constraint must allow for that operand to be in memory rather than a -register. In the example shown above, that is handled by using a loop -instruction sequence that can handle memory operands when the memory -alternative appears. +register. In the example shown above, that is handled (in the +@code{doloop_end_nocc} pattern) by using a loop instruction sequence +that can handle memory operands when the memory alternative appears. +GCC does not check the mode of the loop register operand when generating +the @code{doloop_end} pattern. If the pattern is only valid for some +modes but not others, the pattern should be a @code{define_expand} +pattern that checks the operand mode in the preparation code, and issues +@code{FAIL} if an unsupported mode is found. The example above does +this, since the machine instruction to be used only exists for +@code{HImode}. + +If the @code{doloop_end} pattern is a @code{define_expand}, there must +also be a @code{define_insn} or @code{define_insn_and_split} matching +the generated pattern. Otherwise, the compiler will fail during loop +optimization. + @end ifset @ifset INTERNALS @node Insn Canonicalizations