From patchwork Tue Jan 21 08:35:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1226310 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-517856-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=mZZZQZxR; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jADFo22N; 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 48221s3Sc4z9sRf for ; Tue, 21 Jan 2020 19:36:17 +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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=Dx5 f1Nm9RjKdl8X6rvaNTbWpB8O6uxRKLbA2xb8rnRDFjpu8xowiz/HGRAEyBR/Z5ic J4Jsq/btwH4Eya0MvJ4x/14MkuykTRqFDHViO3YG1ufqE466qY/Evz1Z5qxOglpL erdIQCsAvWKpsQIhYRIIFc82DWk7vKJmPqQINKsA= 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:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; s=default; bh=HmjlagMnZ b+8QFDx+RvgTuW5kjw=; b=mZZZQZxRx/Nj/oM4pIHYzEZowZeBTuBhXFVmd0msD t0sb4eLhoj70detJ2MNglRNeJ2yVl0dWqqO/bxr+mlD5StgKc2nTfxP9W29Rz+3Y /lJ4IyfjfKaiz9PqXFlbYZCN6UoJoToojOmnyS5/dL45UQz1cbqKL7IiANyZxV6C Go= Received: (qmail 107305 invoked by alias); 21 Jan 2020 08:36:09 -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 107294 invoked by uid 89); 21 Jan 2020 08:36:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Jan 2020 08:36:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579595763; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yViqaUKJH5JUfas2YQNXir1DkZ4648NKnMDtuLrsQBo=; b=jADFo22NL84H+cwfPNZCilq3558Z5BiUlSmhnjcPZUURdX4FthZCsrx9vQTxsYX29iMED7 sr7Q9sFqZyfcThXXht0+oYqX3B/tA0wRf6ysjUWZf34KokSotNMe+PxX+W/ks1gEQwE+BD i1BDmruPZCagOFaiCFrMa17QzRYsE4c= 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-14-uKhw8zzqMLmw3e2-gyOI9w-1; Tue, 21 Jan 2020 03:36:00 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 866C9800D41; Tue, 21 Jan 2020 08:35:59 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-51.ams2.redhat.com [10.36.116.51]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1BBF710002A2; Tue, 21 Jan 2020 08:35:58 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id 00L8ZuT5010474; Tue, 21 Jan 2020 09:35:57 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 00L8Ztbd010473; Tue, 21 Jan 2020 09:35:55 +0100 Date: Tue, 21 Jan 2020 09:35:55 +0100 From: Jakub Jelinek To: Jim Wilson Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] riscv: Fix up riscv_rtx_costs for RTL checking (PR target/93333) Message-ID: <20200121083555.GR10088@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-IsSubscribed: yes Hi! As mentioned in the PR, during combine rtx_costs can be called sometimes even on RTL that has not been validated yet and so can contain even operands that aren't valid in any instruction. The following patch ought to fix this case, ok for trunk? 2020-01-21 Jakub Jelinek PR target/93333 * config/riscv/riscv.c (riscv_rtx_costs) : Verify the last two operands are CONST_INT_P before using them as such. * gcc.c-torture/compile/pr93333.c: New test. Jakub --- gcc/config/riscv/riscv.c.jj 2020-01-21 09:14:07.500268371 +0100 +++ gcc/config/riscv/riscv.c 2020-01-21 09:27:37.629974828 +0100 @@ -1642,7 +1642,10 @@ riscv_rtx_costs (rtx x, machine_mode mod case ZERO_EXTRACT: /* This is an SImode shift. */ - if (outer_code == SET && (INTVAL (XEXP (x, 2)) > 0) + if (outer_code == SET + && CONST_INT_P (XEXP (x, 1)) + && CONST_INT_P (XEXP (x, 2)) + && (INTVAL (XEXP (x, 2)) > 0) && (INTVAL (XEXP (x, 1)) + INTVAL (XEXP (x, 2)) == 32)) { *total = COSTS_N_INSNS (SINGLE_SHIFT_COST); --- gcc/testsuite/gcc.c-torture/compile/pr93333.c.jj 2020-01-21 09:27:25.710155732 +0100 +++ gcc/testsuite/gcc.c-torture/compile/pr93333.c 2020-01-21 09:27:08.234420958 +0100 @@ -0,0 +1,10 @@ +/* PR target/93333 */ + +unsigned +foo (int b, int c, int d, unsigned long e, int x, int y, int g, int h, + unsigned i) +{ + e >>= b; + i >>= e & 31; + return i & 1; +}