From patchwork Fri Nov 25 08:25:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominik Vogt X-Patchwork-Id: 699097 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 3tQ8LC70W9z9t2n for ; Fri, 25 Nov 2016 19:26:27 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="YM1UbfE8"; 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:date :from:to:subject:reply-to:references:mime-version:content-type :in-reply-to:message-id; q=dns; s=default; b=Xfg3Dr3XgOmcOqZPJCI 5igj4xARpxw2+1k3M9V3P9o9sMUUbUvUtuJnZj5wMwoyHWL93au+mso1h7OXcBu6 xMh3bsM1J3kxxH25bFd/YK4onyB8CXwKym1R00W8b9Lqy15R8l7SQG2/71bATjFj SWEruaC6D9flZ9QnIxkL3fdA= 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:date :from:to:subject:reply-to:references:mime-version:content-type :in-reply-to:message-id; s=default; bh=aJ3TrCD1yzX04Mvo/MwXdQV66 G0=; b=YM1UbfE8F7JI4vKgVNW84wpd78Spxmzp9xt55pJWCBkU25vdUyGLpwK1C vqGbesB4y/I4UqmvyIeRsKZCiWkMvCwW8KQI5MOD9MmytZ6spXy55Dg5g4vV6Oz9 GjRi1cQ8UhnVYifLY+8bCbo4wwIiPuBT4sRBmbHDhFtmwQhWDU= Received: (qmail 9435 invoked by alias); 25 Nov 2016 08:26:18 -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 9338 invoked by uid 89); 25 Nov 2016 08:26:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=Starting, eb, 2128, nn X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 Nov 2016 08:26:07 +0000 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uAP8O36Q122487 for ; Fri, 25 Nov 2016 03:26:06 -0500 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 26x7t0sep1-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 25 Nov 2016 03:26:05 -0500 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 25 Nov 2016 08:26:04 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 25 Nov 2016 08:26:02 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 20E012190023 for ; Fri, 25 Nov 2016 08:25:14 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uAP8Q24D31719490; Fri, 25 Nov 2016 08:26:02 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D17AB11C04A; Fri, 25 Nov 2016 07:24:15 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 61DE811C054; Fri, 25 Nov 2016 07:24:15 +0000 (GMT) Received: from oc5510024614.ibm.com (unknown [9.145.29.2]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 25 Nov 2016 07:24:15 +0000 (GMT) Received: by oc5510024614.ibm.com (Postfix, from userid 500) id E9CC91AA21; Fri, 25 Nov 2016 09:25:59 +0100 (CET) Date: Fri, 25 Nov 2016 09:25:59 +0100 From: Dominik Vogt To: gcc-patches@gcc.gnu.org, Andreas Krebbel Subject: Re: [PATCH 2/2 v3] PR77822 Reply-To: vogt@linux.vnet.ibm.com Mail-Followup-To: vogt@linux.vnet.ibm.com, gcc-patches@gcc.gnu.org, Andreas Krebbel References: <20161117155303.GA21578@linux.vnet.ibm.com> <20161117155417.GC21578@linux.vnet.ibm.com> <20161121110541.GB16263@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20161121110541.GB16263@linux.vnet.ibm.com> User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16112508-0040-0000-0000-000002696660 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16112508-0041-0000-0000-000022B60F57 Message-Id: <20161125082559.GA6343@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-11-25_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1611250149 On Mon, Nov 21, 2016 at 12:05:42PM +0100, Dominik Vogt wrote: > On Thu, Nov 17, 2016 at 04:54:17PM +0100, Dominik Vogt wrote: > > On Thu, Nov 17, 2016 at 04:53:03PM +0100, Dominik Vogt wrote: > > > The following two patches fix PR 77822 on s390x for gcc-7. As the > > > macro doing the argument range checks can be used on other targets > > > as well, I've put it in system.h (couldn't think of a better > > > place; maybe rtl.h?). > > > > > > Bootstrapped on s390x biarch, regression tested on s390x biarch > > > and s390, all on a zEC12 with -march=zEC12. > > > > > > Please check the commit messages for details. > > > > S390 backend patch. Version 4 of the patchset. Bootstrapped and regression tested on s390 biarch and s390. Changes since the first version of the patchset: v2: Add s390 test cases. Support .cxx tests in s390.exp. Put all arguments of SIZE_POS_IN_RANGE in parentheses. Rewrite SIZE_POS_IN_RANGE macro to handle wrapping SIZE + POS. v3: Rename macro argument from UPPER back to RANGE. v4: Rename SIZE_POS_IN_RANGE to EXTRACT_ARGS_IN_RANGE and move it to rtl.h. Ciao Dominik ^_^ ^_^ diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index a449b03..aaf8427 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -3741,6 +3741,8 @@ (clobber (reg:CC CC_REGNUM))])] "TARGET_Z10" { + if (! EXTRACT_ARGS_IN_RANGE (INTVAL (operands[2]), INTVAL (operands[3]), 64)) + FAIL; /* Starting with zEC12 there is risbgn not clobbering CC. */ if (TARGET_ZEC12) { @@ -3760,7 +3762,9 @@ (match_operand 2 "const_int_operand" "") ; size (match_operand 3 "const_int_operand" ""))) ; start ] - "" + " + && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[2]), INTVAL (operands[3]), + GET_MODE_BITSIZE (mode))" "\t%0,%1,64-%2,128+63,%3+%2" ; dst, src, start, end, shift [(set_attr "op_type" "RIE") (set_attr "z10prop" "z10_super_E1")]) @@ -3773,6 +3777,7 @@ (lshiftrt:DI (match_operand:DI 3 "register_operand" "d") (match_operand:DI 4 "nonzero_shift_count_operand" "")))] " + && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), INTVAL (operands[2]), 64) && 64 - UINTVAL (operands[4]) >= UINTVAL (operands[1])" "\t%0,%3,%2,%2+%1-1,128-%2-%1-%4" [(set_attr "op_type" "RIE") @@ -3791,6 +3796,7 @@ (match_operand 5 "const_int_operand" "")) ; start 4)))] " + && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[4]), INTVAL (operands[5]), 64) && UINTVAL (operands[2]) == (~(0ULL) << UINTVAL (operands[4]))" "\t%0,%3,64-%4,63,%4+%5" [(set_attr "op_type" "RIE") @@ -3804,7 +3810,8 @@ (const_int 1) ; size (match_operand 2 "const_int_operand" "")) ; start (const_int 0)))] - "" + " + && EXTRACT_ARGS_IN_RANGE (1, INTVAL (operands[2]), 64)" "\t%0,%1,64-1,128+63,%2+1" ; dst, src, start, end, shift [(set_attr "op_type" "RIE") (set_attr "z10prop" "z10_super_E1")]) @@ -3919,6 +3926,8 @@ (match_operand 2 "const_int_operand" "I")) ; pos (match_operand:GPR 3 "nonimmediate_operand" "d"))] " + && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), INTVAL (operands[2]), + GET_MODE_BITSIZE (mode)) && (INTVAL (operands[1]) + INTVAL (operands[2])) <= " "\t%0,%3,%2,%2+%1-1,-%2-%1" [(set_attr "op_type" "RIE") @@ -4214,6 +4223,7 @@ (match_operand:DI 3 "nonimmediate_operand" "d"))) (clobber (reg:CC CC_REGNUM))] "TARGET_Z10 + && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), INTVAL (operands[2]), 64) && INTVAL (operands[1]) + INTVAL (operands[2]) == 64" "rnsbg\t%0,%3,%2,63,0" [(set_attr "op_type" "RIE")]) @@ -4230,6 +4240,7 @@ (match_operand:DI 4 "nonimmediate_operand" "d"))) (clobber (reg:CC CC_REGNUM))] "TARGET_Z10 + && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), INTVAL (operands[2]), 64) && INTVAL (operands[3]) == 64 - INTVAL (operands[1]) - INTVAL (operands[2])" "rnsbg\t%0,%4,%2,%2+%1-1,%3" [(set_attr "op_type" "RIE")]) @@ -4239,7 +4250,8 @@ (match_operand 1 "const_int_operand" "n,n") (const_int 0)) (match_operand:W 2 "register_operand" "d,d"))] - "INTVAL (operands[1]) > 0 + "EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), 0, 64) + && INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode) && INTVAL (operands[1]) % BITS_PER_UNIT == 0" { @@ -4260,6 +4272,7 @@ (lshiftrt:DI (match_operand:DI 2 "register_operand" "d") (const_int 32)))] "TARGET_ZARCH + && EXTRACT_ARGS_IN_RANGE (INTVAL (operands[1]), 0, 64) && INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= GET_MODE_BITSIZE (SImode) && INTVAL (operands[1]) % BITS_PER_UNIT == 0" @@ -4278,6 +4291,7 @@ (match_operand 1 "const_int_operand" "n")) (match_operand:DI 2 "const_int_operand" "n"))] "TARGET_ZARCH + && EXTRACT_ARGS_IN_RANGE (16, INTVAL (operands[1]), 64) && INTVAL (operands[1]) >= 0 && INTVAL (operands[1]) < BITS_PER_WORD && INTVAL (operands[1]) % 16 == 0" diff --git a/gcc/testsuite/gcc.target/s390/pr77822-1.cxx b/gcc/testsuite/gcc.target/s390/pr77822-1.cxx new file mode 100644 index 0000000..bd5a9b4 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/pr77822-1.cxx @@ -0,0 +1,21 @@ +/* Regression test for PR/77822. */ + +/* { dg-do compile } */ +/* { dg-options "-O3 -march=zEC12" } */ + +class A { + void m_fn1(); + char m_datawidth; + char m_subunits; + int m_subunit_infos[]; +}; +int a; +long b; +void A::m_fn1() { + int c = 32, d = m_datawidth / c; + for (int e = 0; e < d; e++) { + int f = e * 32; + if (b >> f & 1) + m_subunit_infos[m_subunits] = a; + } +} diff --git a/gcc/testsuite/gcc.target/s390/pr77822-2.c b/gcc/testsuite/gcc.target/s390/pr77822-2.c new file mode 100644 index 0000000..6789152 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/pr77822-2.c @@ -0,0 +1,307 @@ +/* This testcase checks that the shift operand of r*sbg instructions is in + range. */ + +/* { dg-do compile } */ +/* { dg-options "-O3 -march=zEC12 -Wno-shift-count-overflow" } */ + +int g; + +void pos_ll_129 (long long b) +{ + if (b >> 129 & 1) + g = b; +} + +void sizepos_ll_134 (long long b) +{ + if (b >> 134 & 1) + g = b; +} + +void pos_ll_65 (long long b) +{ + if (b >> 65 & 1) + g = b; +} + +void sizepos_ll_70 (long long b) +{ + if (b >> 70 & 1) + g = b; +} + +void pos_ll_33 (long long b) +{ + if (b >> 33 & 1) + g = b; +} + +void sizepos_ll_38 (long long b) +{ + if (b >> 38 & 1) + g = b; +} + +void pos_ll_17 (long long b) +{ + if (b >> 17 & 1) + g = b; +} + +void sizepos_ll_22 (long long b) +{ + if (b >> 22 & 1) + g = b; +} + +void pos_ll_8 (long long b) +{ + if (b >> 8 & 1) + g = b; +} + +void sizepos_ll_13 (long long b) +{ + if (b >> 13 & 1) + g = b; +} + +void pos_l_129 (long b) +{ + if (b >> 129 & 1) + g = b; +} + +void sizepos_l_134 (long b) +{ + if (b >> 134 & 1) + g = b; +} + +void pos_l_65 (long b) +{ + if (b >> 65 & 1) + g = b; +} + +void sizepos_l_70 (long b) +{ + if (b >> 70 & 1) + g = b; +} + +void pos_l_33 (long b) +{ + if (b >> 33 & 1) + g = b; +} + +void sizepos_l_38 (long b) +{ + if (b >> 38 & 1) + g = b; +} + +void pos_l_17 (long b) +{ + if (b >> 17 & 1) + g = b; +} + +void sizepos_l_22 (long b) +{ + if (b >> 22 & 1) + g = b; +} + +void pos_l_8 (long b) +{ + if (b >> 8 & 1) + g = b; +} + +void sizepos_l_13 (long b) +{ + if (b >> 13 & 1) + g = b; +} + +void pos_i_129 (int b) +{ + if (b >> 129 & 1) + g = b; +} + +void sizepos_i_134 (int b) +{ + if (b >> 134 & 1) + g = b; +} + +void pos_i_65 (int b) +{ + if (b >> 65 & 1) + g = b; +} + +void sizepos_i_70 (int b) +{ + if (b >> 70 & 1) + g = b; +} + +void pos_i_33 (int b) +{ + if (b >> 33 & 1) + g = b; +} + +void sizepos_i_38 (int b) +{ + if (b >> 38 & 1) + g = b; +} + +void pos_i_17 (int b) +{ + if (b >> 17 & 1) + g = b; +} + +void sizepos_i_22 (int b) +{ + if (b >> 22 & 1) + g = b; +} + +void pos_i_8 (int b) +{ + if (b >> 8 & 1) + g = b; +} + +void sizepos_i_13 (int b) +{ + if (b >> 13 & 1) + g = b; +} + +void pos_s_129 (short b) +{ + if (b >> 129 & 1) + g = b; +} + +void sizepos_s_134 (short b) +{ + if (b >> 134 & 1) + g = b; +} + +void pos_s_65 (short b) +{ + if (b >> 65 & 1) + g = b; +} + +void sizepos_s_70 (short b) +{ + if (b >> 70 & 1) + g = b; +} + +void pos_s_33 (short b) +{ + if (b >> 33 & 1) + g = b; +} + +void sizepos_s_38 (short b) +{ + if (b >> 38 & 1) + g = b; +} + +void pos_s_17 (short b) +{ + if (b >> 17 & 1) + g = b; +} + +void sizepos_s_22 (short b) +{ + if (b >> 22 & 1) + g = b; +} + +void pos_s_8 (short b) +{ + if (b >> 8 & 1) + g = b; +} + +void sizepos_s_13 (short b) +{ + if (b >> 13 & 1) + g = b; +} + +void pos_c_129 (signed char b) +{ + if (b >> 129 & 1) + g = b; +} + +void sizepos_c_134 (signed char b) +{ + if (b >> 134 & 1) + g = b; +} + +void pos_c_65 (signed char b) +{ + if (b >> 65 & 1) + g = b; +} + +void sizepos_c_70 (signed char b) +{ + if (b >> 70 & 1) + g = b; +} + +void pos_c_33 (signed char b) +{ + if (b >> 33 & 1) + g = b; +} + +void sizepos_c_38 (signed char b) +{ + if (b >> 38 & 1) + g = b; +} + +void pos_c_17 (signed char b) +{ + if (b >> 17 & 1) + g = b; +} + +void sizepos_c_22 (signed char b) +{ + if (b >> 22 & 1) + g = b; +} + +void pos_c_8 (signed char b) +{ + if (b >> 8 & 1) + g = b; +} + +void sizepos_c_13 (signed char b) +{ + if (b >> 13 & 1) + g = b; +} diff --git a/gcc/testsuite/gcc.target/s390/s390.exp b/gcc/testsuite/gcc.target/s390/s390.exp index f4ad7a1..69c1f39 100644 --- a/gcc/testsuite/gcc.target/s390/s390.exp +++ b/gcc/testsuite/gcc.target/s390/s390.exp @@ -90,16 +90,16 @@ dg-init set md_tests $srcdir/$subdir/md/*.c # Main loop. -dg-runtest [lsort [prune [glob -nocomplain $srcdir/$subdir/*.\[cS\]] \ +dg-runtest [lsort [prune [glob -nocomplain $srcdir/$subdir/*.{c,S,cxx}] \ $md_tests]] "" $DEFAULT_CFLAGS -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*vector*/*.\[cS\]]] \ +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*vector*/*.]] \ "" $DEFAULT_CFLAGS -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/target-attribute/*.\[cS\]]] \ +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/target-attribute/*.{c,S,cxx}]] \ "" $DEFAULT_CFLAGS -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/md/*.\[cS\]]] \ +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/md/*.{c,S,cxx}]] \ "" $DEFAULT_CFLAGS # Additional hotpatch torture tests.