From patchwork Mon Jun 19 07:16:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 777612 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 3wrj3H0QHlz9s76 for ; Mon, 19 Jun 2017 17:17:13 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="rEOYwMq9"; 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:message-id:mime-version:content-type; q=dns; s= default; b=RG+TX1QdwY8KmxAdU1Qx/yGVyuywafy6KfsqBMSk35ObPpq6uyS6J 2tIm8KfX85u97Db1adB4b/CHvKe3Tac7zX2Tzhv7v3rWvrnOE+e1VFYDu9F4X4a1 gd5/DH/uehAS0F3YPObopUAtP7wUwSm+ePlhoucHeVDOts1Mmu82n0= 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:message-id:mime-version:content-type; s= default; bh=0Zldy5mqEpuwTxxHB4sFm+WHxfo=; b=rEOYwMq9YpotUk/JU3ld pSq3pyeHE4DUFmNQvgbwMYy4NICMUBuy23lGN/a8aWuwRC7VPRd2O+gsXuh5bjM9 wXEo+x8NpLNvSv59+tCHPFHTZH0oWPO2+VKiB8QvwHHYxkFl5tE9ZxIS4vLfKfiV 6wi9lm6NohSg5nkKHJQV9xU= Received: (qmail 77782 invoked by alias); 19 Jun 2017 07:16:58 -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 77770 invoked by uid 89); 19 Jun 2017 07:16:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-16.1 required=5.0 tests=BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=uuid X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 19 Jun 2017 07:16:56 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2B00EABFC for ; Mon, 19 Jun 2017 07:16:59 +0000 (UTC) Date: Mon, 19 Jun 2017 09:16:58 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR81112 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 The following fixes an ommision in find_constructor_constant_at_offset to handle RANGE_EXPR in array constructor indices. The handling is conservative in that it only handles the first index in the range. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk sofar. Richard. 2017-06-19 Richard Biener PR ipa/81112 * ipa-prop.c (find_constructor_constant_at_offset): Handle RANGE_EXPR conservatively. * g++.dg/torture/pr81112.C: New testcase. Index: gcc/ipa-prop.c =================================================================== --- gcc/ipa-prop.c (revision 249245) +++ gcc/ipa-prop.c (working copy) @@ -3030,7 +3030,10 @@ find_constructor_constant_at_offset (tre if (index) { - off = wi::to_offset (index); + if (TREE_CODE (index) == RANGE_EXPR) + off = wi::to_offset (TREE_OPERAND (index, 0)); + else + off = wi::to_offset (index); if (TYPE_DOMAIN (type) && TYPE_MIN_VALUE (TYPE_DOMAIN (type))) { tree low_bound = TYPE_MIN_VALUE (TYPE_DOMAIN (type)); @@ -3039,6 +3042,8 @@ find_constructor_constant_at_offset (tre TYPE_PRECISION (TREE_TYPE (index))); } off *= wi::to_offset (unit_size); + /* ??? Handle more than just the first index of a + RANGE_EXPR. */ } else off = wi::to_offset (unit_size) * ix; Index: gcc/testsuite/g++.dg/torture/pr81112.C =================================================================== --- gcc/testsuite/g++.dg/torture/pr81112.C (nonexistent) +++ gcc/testsuite/g++.dg/torture/pr81112.C (working copy) @@ -0,0 +1,67 @@ +// { dg-do compile } + +class AssertionResult { + bool success_; +}; + +AssertionResult AssertionSuccess(); + +template +AssertionResult EXPECT_EQ(const T1& expected, const T1& actual) { + if (expected == actual) { + return AssertionSuccess(); + } + return AssertionSuccess(); +} + +struct uuid +{ + unsigned char data[16]; +}; + +bool operator== (uuid const& lhs, uuid const& rhs); + +typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__)); +typedef int __v4si __attribute__ ((__vector_size__ (16))); +typedef char __v16qi __attribute__ ((__vector_size__ (16))); +typedef long long __m128i_u __attribute__ ((__vector_size__ (16), __may_alias__, __aligned__ (1))); + +int foo (__v16qi); + +extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_loadu_si128 (__m128i_u const *__P) +{ + return *__P; +} +extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_cmpeq_epi32 (__m128i __A, __m128i __B) +{ + return (__m128i) ((__v4si)__A == (__v4si)__B); +} +extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__)) + _mm_movemask_epi8 (__m128i __A) +{ + return foo ((__v16qi)__A); +} + + +__m128i load_unaligned_si128(const unsigned char* p) +{ + return _mm_loadu_si128(reinterpret_cast< const __m128i* >(p)); +} + +inline bool operator== (uuid const& lhs, uuid const& rhs) +{ + __m128i mm_left = load_unaligned_si128(lhs.data); + __m128i mm_right = load_unaligned_si128(rhs.data); + + __m128i mm_cmp = _mm_cmpeq_epi32(mm_left, mm_right); + + return _mm_movemask_epi8(mm_cmp) == 0xFFFF; +} + +void crash_gcc7() +{ + static const uuid u = uuid(); + EXPECT_EQ(u, u); +}