From patchwork Wed Apr 11 13:11:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 897188 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-476211-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.b="amJ8BaVG"; 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 40LlRg3s3kz9s1B for ; Wed, 11 Apr 2018 23:35:59 +1000 (AEST) 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; q=dns; s=default; b=BAX87hgmd/RPN6RVCcniKIg2cGRRn 7JV6JNRhTOO3qQbNqeromxR/4ndE1Rc/x9FM3xe8WN1mmI/EqEK0WYkI3Vq4ao+d cPSoLpxfTp/nTwzNbaRlqw23EiV22lptZbaOMboiO+qsbJkEHU/scPS/r0LKF2bd ENS6pNLGwIxf0k= 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; s=default; bh=NBGZc+IaRKJwUVEgjGGWE2Vqo9o=; b=amJ 8BaVGIx6wbM3GkhJg0/jfoxbT8Fzjkaek6I5HLHosRpM9EjPOiuJHSD0i5JDDxnV xcxc+GGvkqL/aHyA9Ei+M5Mwf9LS7w/dfmACaNQlrnhWFjIkh8GbaP2lY9jMWVBc Q2P1QeGz166+djWx4fOtcU2iXQjWYeYb9eDYhvIA= Received: (qmail 10971 invoked by alias); 11 Apr 2018 13:35:43 -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 10673 invoked by uid 89); 11 Apr 2018 13:35:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Apr 2018 13:35:39 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7DB0CFBE7E for ; Wed, 11 Apr 2018 13:35:28 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.36.118.110]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C27A2023227 for ; Wed, 11 Apr 2018 13:35:27 +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 w3BDBRR8006496; Wed, 11 Apr 2018 15:11:28 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w3BDBQUQ006495; Wed, 11 Apr 2018 15:11:26 +0200 Date: Wed, 11 Apr 2018 15:11:26 +0200 From: Jakub Jelinek To: Richard Biener , Richard Sandiford Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix VEC_PERM_EXPR folding (PR tree-optimization/85331) Message-ID: <20180411131126.GR8577@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes Hi! We ICE on the following testcase, because VEC_PERM_EXPR indexes are supposed to be clamped into the 0 .. 2 * nelts - 1 range, but if some index is very large constant (larger or equal than HOST_WIDE_INT_1 << 33), then clamp doesn't actually perform any clamping. This is because can_div_trunc_p stores the quotient into int variable and this doesn't fit in that case into int. As element_type is poly_int64, it should fit into HOST_WIDE_INT. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-04-11 Jakub Jelinek PR tree-optimization/85331 * vec-perm-indices.h (vec_perm_indices::clamp): Change input type from int to HOST_WIDE_INT. * gcc.c-torture/execute/pr85331.c: New test. Jakub --- gcc/vec-perm-indices.h.jj 2018-01-03 10:19:54.969533927 +0100 +++ gcc/vec-perm-indices.h 2018-04-11 09:48:02.043153054 +0200 @@ -119,7 +119,7 @@ inline vec_perm_indices::element_type vec_perm_indices::clamp (element_type elt) const { element_type limit = input_nelts (), elem_within_input; - int input; + HOST_WIDE_INT input; if (!can_div_trunc_p (elt, limit, &input, &elem_within_input)) return elt; --- gcc/testsuite/gcc.c-torture/execute/pr85331.c.jj 2018-04-11 09:54:02.044206856 +0200 +++ gcc/testsuite/gcc.c-torture/execute/pr85331.c 2018-04-11 09:53:22.359200922 +0200 @@ -0,0 +1,22 @@ +/* PR tree-optimization/85331 */ + +typedef double V __attribute__((vector_size (2 * sizeof (double)))); +typedef long long W __attribute__((vector_size (2 * sizeof (long long)))); + +__attribute__((noipa)) void +foo (V *r) +{ + V y = { 1.0, 2.0 }; + W m = { 10000000001LL, 0LL }; + *r = __builtin_shuffle (y, m); +} + +int +main () +{ + V r; + foo (&r); + if (r[0] != 2.0 || r[1] != 1.0) + __builtin_abort (); + return 0; +}