From patchwork Fri Jan 13 11:53:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 715003 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 3v0Lcx4FsKz9s3v for ; Fri, 13 Jan 2017 22:53:53 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="pWsda/Q0"; 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:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=knTUSq16B+pZQsIe4UaVGDVpas4wild3k4/DmRm+cLua0Md/Xm 8It5LIfUltmqCMv9TRuBtl3hZIM4lSXfbljph+PqwyYqziuJ6mGaCQ9+NTLchoBP hkjH99yV8ItgVJJxNsRJbNPu69nObjwYE4tV5PKJ/gHf0PRAH6FBbikQY= 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:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=8e7yN8ExIz53Rndql8CqJIkqNv0=; b=pWsda/Q0J6wc3xJdHBOK YF7l/cTCNPlsJBzjVbG8koIguV8zO/+Ba+VEYc4x0oua2qBoLCkL6w00xa8K8Vzg XMoi4fYYkgPXTznbu5RqLw/jrVxookNpU6RCeZO5PSVQLAc7Ubuj34jxZnmlO/Rs gZAzfjcnmv4wYpw5AcBO2rU= Received: (qmail 61801 invoked by alias); 13 Jan 2017 11:53:30 -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 61714 invoked by uid 89); 13 Jan 2017 11:53:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=gcc_target, treepassh, UD:context.h, tree-pass.h X-HELO: mo4-p00-ob.smtp.rzone.de Received: from mo4-p00-ob.smtp.rzone.de (HELO mo4-p00-ob.smtp.rzone.de) (81.169.146.161) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Jan 2017 11:53:19 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT3ol15ykJcYwTPLBCxG2PQt7BpWLF2I= X-RZG-CLASS-ID: mo00 Received: from [192.168.0.123] ([95.88.113.187]) by smtp.strato.de (RZmta 39.11 DYNA|AUTH) with ESMTPSA id 606798t0DBrFIVO (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Fri, 13 Jan 2017 12:53:15 +0100 (CET) To: gcc-patches Cc: Denis Chertykov From: Georg-Johann Lay Subject: [patch,avr]: For PR78883 #3 Message-ID: <6e9eb31e-7d95-ca82-6615-0056e5e2f9fe@gjlay.de> Date: Fri, 13 Jan 2017 12:53:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 X-IsSubscribed: yes This is 3rd way to fix PR78883 by rejecting malicious expressions from the start. Ok for trunk? Johann gcc/ PR target/78883 * config/avr/avr.c (rtl-iter.h): Include it. (TARGET_LEGITIMATE_COMBINED_INSN): New hook define... (avr_legitimate_combined_insn): ...and implementation. gcc/testsuite/ PR target/78883 * gcc.c-torture/compile/pr78883.c: New test. Index: config/avr/avr.c =================================================================== --- config/avr/avr.c (revision 244001) +++ config/avr/avr.c (working copy) @@ -49,6 +49,7 @@ #include "context.h" #include "tree-pass.h" #include "print-rtl.h" +#include "rtl-iter.h" /* This file should be included last. */ #include "target-def.h" @@ -12823,6 +12824,34 @@ avr_convert_to_type (tree type, tree exp } +/* Implement `TARGET_LEGITIMATE_COMBINED_INSN'. */ + +/* PR78883: Filter out paradoxical SUBREGs of MEM which are not handled + properly by following passes. As INSN_SCHEDULING is off and hence + general_operand accepts such expressions, ditch them now. */ + +static bool +avr_legitimate_combined_insn (rtx_insn *insn) +{ + subrtx_iterator::array_type array; + + FOR_EACH_SUBRTX (iter, array, PATTERN (insn), NONCONST) + { + const_rtx op = *iter; + + if (SUBREG_P (op) + && MEM_P (SUBREG_REG (op)) + && (GET_MODE_SIZE (GET_MODE (op)) + > GET_MODE_SIZE (GET_MODE (SUBREG_REG (op))))) + { + return false; + } + } + + return true; +} + + /* PR63633: The middle-end might come up with hard regs as input operands. RMASK is a bit mask representing a subset of hard registers R0...R31: @@ -14364,6 +14393,9 @@ avr_fold_builtin (tree fndecl, int n_arg #define TARGET_USE_BY_PIECES_INFRASTRUCTURE_P \ avr_use_by_pieces_infrastructure_p +#undef TARGET_LEGITIMATE_COMBINED_INSN +#define TARGET_LEGITIMATE_COMBINED_INSN avr_legitimate_combined_insn + struct gcc_target targetm = TARGET_INITIALIZER; Index: testsuite/gcc.c-torture/compile/pr78883.c =================================================================== --- testsuite/gcc.c-torture/compile/pr78883.c (nonexistent) +++ testsuite/gcc.c-torture/compile/pr78883.c (working copy) @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +int foo (int *p) +{ + int i; + for (i = 0; i < 5; i++) + { + if (p[i] & 1) + return i; + } + return -1; +}