From patchwork Tue Mar 3 07:38:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1248136 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-520507-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=BEfbcVRX; 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=Lw7UyT4X; 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 48Wplx2rjrz9sQt for ; Tue, 3 Mar 2020 18:38:37 +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=x7R EmIQ+wZUDbBFjAK3XEsXuSIGLBtvGJIaTPU8NZQ0JqX2GZ2Ts8hEVD19nhzlppNX erHJgagFecHZwZ0gSMuXq88e1A5Gdri4JzRkQhVj1lEn6/iwL+staIBnq3A5YdNT RN36d/Omvp9kWQwgHOpAVQu1l5PDAuIitNwgxkbw= 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=azhBXMx07 sI0wyh/IOdOK6wIT0o=; b=BEfbcVRXafT+UX7DHQMpnywuC2bW+Jveayf9UqEkS dDBRNnwViHSNbBpUFfJmtM0aTlCVqfDCXfZYEceApIBZ9vNCnhizgPYrqVqN35I5 Ma1n/RE+HRoGNXYdPlZx8QQTLF2gyVTep+3rVX40dUiJui3EsQddJMlL4kdmmpHj l0= Received: (qmail 107570 invoked by alias); 3 Mar 2020 07:38: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 107556 invoked by uid 89); 3 Mar 2020 07:38:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=thusly, HTo:U*ebotcazou X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (205.139.110.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 03 Mar 2020 07:38:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583221107; 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=PxyraD6IUls9dvNRAS9MS/0D3sQ50mtSRenHN6Nstq4=; b=Lw7UyT4XVeDupsryt7AaC0glAk4YkCsXrtmo3Lq38HqtsvfOAYt/4UrZzD+xUIJzQa0Vf1 /OcmmGJKRREvYcpmuTJHDG5YDKccGzFahs6+MmlWYiDLyQ0dc7JUUTp6XMraSrdm8T+uty zPbGM50OJziodylFR9LeQpsGsOmDgSo= 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-356-p6CHWsLGP1irZFi09n-WaQ-1; Tue, 03 Mar 2020 02:38:25 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2461A8017CC; Tue, 3 Mar 2020 07:38:24 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-37.ams2.redhat.com [10.36.116.37]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9B4A55C1D6; Tue, 3 Mar 2020 07:38:23 +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 0237cLJ6002257; Tue, 3 Mar 2020 08:38:21 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 0237cJV5002256; Tue, 3 Mar 2020 08:38:19 +0100 Date: Tue, 3 Mar 2020 08:38:19 +0100 From: Jakub Jelinek To: Richard Biener , Eric Botcazou Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] explow: Fix ICE caused by plus_constant [PR94002] Message-ID: <20200303073819.GX2156@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! The following testcase ICEs in cross to riscv64-linux. The problem is that we have a DImode integral constant (that doesn't fit into SImode), which is pushed into a constant pool and later access just the first half of it using a MEM. When plus_constant is called on such a MEM, if the constant has mode, we verify the mode, but if it doesn't, we don't and ICE later on when we think the CONST_INT is a valid SImode constant. Fixed thusly, tested with cross to riscv64-linux and bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2020-03-03 Jakub Jelinek PR rtl-optimization/94002 * explow.c (plus_constant): Punt if cst has VOIDmode and get_pool_mode is different from mode. * gcc.dg/pr94002.c: New test. Jakub --- gcc/explow.c.jj 2020-01-12 11:54:36.564411130 +0100 +++ gcc/explow.c 2020-03-02 22:09:19.544380020 +0100 @@ -128,6 +128,9 @@ plus_constant (machine_mode mode, rtx x, cst = gen_lowpart (mode, cst); gcc_assert (cst); } + else if (GET_MODE (cst) == VOIDmode + && get_pool_mode (XEXP (x, 0)) != mode) + break; if (GET_MODE (cst) == VOIDmode || GET_MODE (cst) == mode) { tem = plus_constant (mode, cst, c); --- gcc/testsuite/gcc.dg/pr94002.c.jj 2020-03-02 22:05:58.508338170 +0100 +++ gcc/testsuite/gcc.dg/pr94002.c 2020-03-02 22:05:32.864715503 +0100 @@ -0,0 +1,13 @@ +/* PR rtl-optimization/94002 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-tree-dce -fno-tree-reassoc" } */ +/* { dg-additional-options "-fPIC" { target fpic } } */ + +unsigned a, b; + +void +foo (void) +{ + __builtin_sub_overflow (b, 44852956282LL, &a); + a += ~b; +}