From patchwork Sun Sep 4 12:12:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 665514 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 3sRsFp2Zg2z9sdg for ; Sun, 4 Sep 2016 22:13:16 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=QzSyPvSt; 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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=xKPncDaJOSjpg6V4iZT6mjRGPV5y+9XJUAMAfCINwEKRFl yUt5GzLUOniM3BCvB80QiPlu7mmLJkzsteYfDpEatctl54/oBkQprp3mSslpIL57 IfyNM3PxHwvfAICAHcVnXYJCFOtI9oddw8JYBW76vudwrXAwvzuCvVXy/PYbs= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=LKwK/mII8OQKs4khnYq4gUfRUiM=; b=QzSyPvStkoWRk6ZRdXWv zYkx7jP1YCmID3NBICHSVUu5Mo94KkRnfM2oMkZWYhv8PdZkIaENjC3+k0ks7tcM K2DN+UMn44i+YgDmH5BX6WwIr3UHn8p9QqBxGoO4eGpBaH8AH016Dsow7Nb4Tn/4 2FWNNDBu9/nZb61iXXshkt4= Received: (qmail 99203 invoked by alias); 4 Sep 2016 12:13:07 -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 99121 invoked by uid 89); 4 Sep 2016 12:13:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.7 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 spammy=Targets, host_wide, HOST_WIDE, 106, 15 X-HELO: mail-ua0-f182.google.com Received: from mail-ua0-f182.google.com (HELO mail-ua0-f182.google.com) (209.85.217.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 04 Sep 2016 12:12:56 +0000 Received: by mail-ua0-f182.google.com with SMTP id 49so24508184uat.3 for ; Sun, 04 Sep 2016 05:12:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=rXT2vOeDt1XZ/eXlcZ7HycIIOsdBUbUu42vePYHO9aU=; b=ff2YKHAiJ8EvFUatLA+0JW/5y6zHDuWcDj83SVLUqzskPtomz0M5ugIKlvAIqUFxx3 ySHqw6kxGttdrjQovJddCMFWiDTJicmDkQOEuC9A/9eGreK5QqbYCsqipqQEYlr+8GqK TVPpBgb0w6vytyRHOxwdbr7oi9F/L2S4kZ1WNShxlOUtcS0cuCimtpOAmshloS1zDe5/ jVvoSjbJUuo1aMUoZnzsULa2D9Da96Wy3h5BjE7H5hHDgLSeLoZrjEdnqTQm/+ypJbcc UsR3YRwSc/qyd15OsjqrBSYr0uWQxQ5RYor8+kt+b+ZZ1hI6bECaMz5ciPVneg1YmIZ/ JsYA== X-Gm-Message-State: AE9vXwPnKwkWTxrKgt7cLA6WzsFwf2lq0+Fc+SxCQRLcflV2rnztepm0e0la3coJPbGw4QVZnNap8ildDvp2Sw== X-Received: by 10.159.41.231 with SMTP id s94mr19300665uas.58.1472991174627; Sun, 04 Sep 2016 05:12:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.21.134 with HTTP; Sun, 4 Sep 2016 05:12:53 -0700 (PDT) From: Uros Bizjak Date: Sun, 4 Sep 2016 14:12:53 +0200 Message-ID: Subject: [PATCH, rtl-optimization]: Fix PR77452, ICE: in plus_constant, at explow.c To: "gcc-patches@gcc.gnu.org" Hello! As shown in the PR [1], combine is able to simplify lowpart CONST_VECTOR constant pool reference to its inner-mode reference. However, plus_constant was not able to extract the constant from narrowed access. Attached patch teaches plus_constant how to handle this situation. 2016-09-04 Uros Bizjak PR rtl-optimization/77452 * explow.c (plus_constant) : Extract scalar constant from inner-mode reference to a CONST_VECTOR constant in the constant pool. 2016-09-04 Uros Bizjak testsuite/ChangeLog: PR rtl-optimization/77452 * gcc.target/i386/pr77452.c: New test. Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. OK for mainline and gcc-6 branch? [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77452 Uros. Index: explow.c =================================================================== --- explow.c (revision 239975) +++ explow.c (working copy) @@ -106,7 +106,15 @@ plus_constant (machine_mode mode, rtx x, HOST_WIDE if (GET_CODE (XEXP (x, 0)) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (XEXP (x, 0))) { - tem = plus_constant (mode, get_pool_constant (XEXP (x, 0)), c); + rtx cst = get_pool_constant (XEXP (x, 0)); + + if (GET_CODE (cst) == CONST_VECTOR + && GET_MODE_INNER (GET_MODE (cst)) == mode) + { + cst = gen_lowpart (mode, cst); + gcc_assert (cst); + } + tem = plus_constant (mode, cst, c); tem = force_const_mem (GET_MODE (x), tem); /* Targets may disallow some constants in the constant pool, thus force_const_mem may return NULL_RTX. */ Index: testsuite/gcc.target/i386/pr77452.c =================================================================== --- testsuite/gcc.target/i386/pr77452.c (nonexistent) +++ testsuite/gcc.target/i386/pr77452.c (working copy) @@ -0,0 +1,13 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O -mavx512f -fno-split-wide-types --param max-combine-insns=2" } */ + +typedef unsigned int U __attribute__((vector_size(64))); +typedef unsigned __int128 V __attribute__((vector_size(64))); + +V +foo(V v) +{ + v[0] = 1u << (( ((V)(U){1, 1, v[0]})[0]) & 0xf) + >> ((-~((V)(U){1, 1, v[0]})[0]) & 0xf); + return v; +}