From patchwork Tue Apr 3 16:07:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 894679 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-475767-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="sqmta4iY"; 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 40FvBv1QBMz9s0q for ; Wed, 4 Apr 2018 02:08:07 +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=Or1tv0LZmP7IQ8r3uuvCQnEU8U4qL DyBKobxZwAKV2NDiGiYEPdYJwa+KIje7JaaGS35a+d2juP56RxrxiEex6expQ/PA feLeBFslEycvm3eWkaPFuvgQ6Z1PusAy9n4rCHVeL/Nvt9U1xJe+z5xnrSAH0T+T X/kh0k7OelXavQ= 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=+2vXEZ3dDXfHJ63vkmtSxx9LqJ8=; b=sqm ta4iY6jcRc7yfR2LSi5nU8nOPg2ZXABmmh9SeoapGOB7lSdPDK4l+yhSuIFIH74E RccZzSq7T/yk8wVOFbKmnWjOL7FccSdT2Ez4LOOntVPBv31iJ9B9mqbZELQAnVZR X+zAarLNzNZhvQzKNZHUpe5O0ZgT2OGe3OySUfrE= Received: (qmail 51937 invoked by alias); 3 Apr 2018 16:07:18 -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 51865 invoked by uid 89); 3 Apr 2018 16:07:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, T_RP_MATCHES_RCVD 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; Tue, 03 Apr 2018 16:07:16 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11C8D76FBA; Tue, 3 Apr 2018 16:07:15 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.36.118.110]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C37F8215CDAF; Tue, 3 Apr 2018 16:07:14 +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 w33G7Chq011595; Tue, 3 Apr 2018 18:07:13 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w33G7CEV011594; Tue, 3 Apr 2018 18:07:12 +0200 Date: Tue, 3 Apr 2018 18:07:12 +0200 From: Jakub Jelinek To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [committed] Fix ix86_expand_vector_set for V64QImode (PR target/85169) Message-ID: <20180403160712.GC8577@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! For V64QImode, elt can be 0 to 63, so 1 << elt invokes UB in the compiler and we get wrong masks. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk as obvious. 2018-04-03 Jakub Jelinek PR target/85169 * config/i386/i386.c (ix86_expand_vector_set): Use HOST_WIDE_INT_1U << elt instead of 1 << elt. Formatting fix. * gcc.c-torture/execute/pr85169.c: New test. * gcc.target/i386/avx512f-pr85169.c: New test. * gcc.target/i386/avx512bw-pr85169.c: New test. Jakub --- gcc/config/i386/i386.c.jj 2018-04-01 08:03:37.938565056 +0200 +++ gcc/config/i386/i386.c 2018-04-03 12:40:43.181665150 +0200 @@ -44163,12 +44163,14 @@ quarter: where the mask is clear and second input operand otherwise. */ emit_insn (gen_blendm (target, target, tmp, force_reg (mmode, - gen_int_mode (1 << elt, mmode)))); + gen_int_mode (HOST_WIDE_INT_1U << elt, + mmode)))); } else if (use_vec_merge) { tmp = gen_rtx_VEC_DUPLICATE (mode, val); - tmp = gen_rtx_VEC_MERGE (mode, tmp, target, GEN_INT (1 << elt)); + tmp = gen_rtx_VEC_MERGE (mode, tmp, target, + GEN_INT (HOST_WIDE_INT_1U << elt)); emit_insn (gen_rtx_SET (target, tmp)); } else @@ -44177,7 +44179,7 @@ quarter: emit_move_insn (mem, target); - tmp = adjust_address (mem, inner_mode, elt*GET_MODE_SIZE (inner_mode)); + tmp = adjust_address (mem, inner_mode, elt * GET_MODE_SIZE (inner_mode)); emit_move_insn (tmp, val); emit_move_insn (target, mem); --- gcc/testsuite/gcc.c-torture/execute/pr85169.c.jj 2018-04-03 12:46:25.167770124 +0200 +++ gcc/testsuite/gcc.c-torture/execute/pr85169.c 2018-04-03 12:45:23.637725937 +0200 @@ -0,0 +1,22 @@ +/* PR target/85169 */ + +typedef char V __attribute__((vector_size (64))); + +static void __attribute__ ((noipa)) +foo (V *p) +{ + V v = *p; + v[63] = 1; + *p = v; +} + +int +main () +{ + V v = (V) { }; + foo (&v); + for (unsigned i = 0; i < 64; i++) + if (v[i] != (i == 63)) + __builtin_abort (); + return 0; +} --- gcc/testsuite/gcc.target/i386/avx512f-pr85169.c.jj 2018-04-03 12:47:03.686797782 +0200 +++ gcc/testsuite/gcc.target/i386/avx512f-pr85169.c 2018-04-03 12:47:36.075821048 +0200 @@ -0,0 +1,18 @@ +/* PR target/85169 */ +/* { dg-do run { target avx512f } } */ +/* { dg-options "-O2 -mavx512f" } */ + +#include "avx512f-check.h" + +int do_main (void); + +static void +avx512f_test (void) +{ + do_main (); +} + +#undef main +#define main() do_main () + +#include "../../gcc.c-torture/execute/pr85169.c" --- gcc/testsuite/gcc.target/i386/avx512bw-pr85169.c.jj 2018-04-03 12:47:59.394837794 +0200 +++ gcc/testsuite/gcc.target/i386/avx512bw-pr85169.c 2018-04-03 12:48:09.441845006 +0200 @@ -0,0 +1,18 @@ +/* PR target/85169 */ +/* { dg-do run { target avx512bw } } */ +/* { dg-options "-O2 -mavx512bw" } */ + +#include "avx512bw-check.h" + +int do_main (void); + +static void +avx512bw_test (void) +{ + do_main (); +} + +#undef main +#define main() do_main () + +#include "../../gcc.c-torture/execute/pr85169.c"