From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120677 invoked by alias); 10 Feb 2020 14:33:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 120652 invoked by uid 89); 10 Feb 2020 14:33:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 10 Feb 2020 14:33:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581345190; 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=zwQXsZAt6DMO5oDYEu2O3DX1XncQEx0zC1aIryVTOM0=; b=hofNgw57Kkjpl2CVsGwHCsGGYzLgfMT5OVlsSckVpWppluU4nnmSmiXQAPT6PKBidzl7pR uRtGBUbTK1pQHqoHAdR0HZz7dy9k5YsvGze+e7yAtobxCRqxZnGptCKztOlhuwEwfB+pvg RmlKjC2RCNbrVqKyaieENewGnAS/jGk= 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-155-MQIXdFnkNEGB8Xk0aZ05_w-1; Mon, 10 Feb 2020 09:32:52 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0116B800D50; Mon, 10 Feb 2020 14:32:51 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-51.ams2.redhat.com [10.36.116.51]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 85FA560BF1; Mon, 10 Feb 2020 14:32:50 +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 01AEWmsN004655; Mon, 10 Feb 2020 15:32:48 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 01AEWlZG004654; Mon, 10 Feb 2020 15:32:47 +0100 Date: Mon, 10 Feb 2020 14:33:00 -0000 From: Jakub Jelinek To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] i386: Fix -mavx -mno-mavx2 ICE with VEC_COND_EXPR [PR93637] Message-ID: <20200210143247.GQ17695@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-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg00544.txt.bz2 Hi! As mentioned in the PR, for -mavx -mno-avx2 the backend does support vcondv4div4df and vcondv8siv8sf optabs (while generally 32-byte vectors aren't much supported in that case, it is performed using vandps/vandnps/vorps). The problem is that after the last generic vector lowering (where the VEC_COND_EXPR still compares two V4DF vectors and has two V4DI last operands and V4DI result and so is considered ok) fre4 folds the condition into constant, at which point the middle-end during expansion will try vcond_mask_optab and fall back to trying to expand it as the constant vector < 0 vcondv4div4di, but neither of them is supported for -mavx -mno-avx2 and thus we ICE. So, the options I see is either what the following patch does, also support vcond_mask_v4div4di and vcond_mask_v4siv4si already for TARGET_AVX, or require for vcondv4div4df and vcondv8siv8sf TARGET_AVX2 rather than current TARGET_AVX. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Or do you prefer the disabling of the vcond patterns instead? 2020-02-10 Jakub Jelinek PR target/93637 * config/i386/sse.md (VI_256_AVX2): New mode iterator. (vcond_mask_): Use it instead of VI_256. Change condition from TARGET_AVX2 to TARGET_AVX. * gcc.target/i386/avx-pr93637.c: New test. --- gcc/config/i386/sse.md.jj 2020-02-10 13:14:02.970131692 +0100 +++ gcc/config/i386/sse.md 2020-02-10 13:15:54.343473253 +0100 @@ -3430,13 +3430,19 @@ (define_expand "vcond_mask_ 3 "register_operand")))] "TARGET_AVX512BW") =20 +;; As vcondv4div4df and vcondv8siv8sf are enabled already with TARGET_AVX, +;; and their condition can be folded late into a constant, we need to +;; support vcond_mask_v4div4di and vcond_mask_v8siv8si for TARGET_AVX. +(define_mode_iterator VI_256_AVX2 [(V32QI "TARGET_AVX2") (V16HI "TARGET_AV= X2") + V8SI V4DI]) + (define_expand "vcond_mask_" - [(set (match_operand:VI_256 0 "register_operand") - (vec_merge:VI_256 - (match_operand:VI_256 1 "nonimmediate_operand") - (match_operand:VI_256 2 "nonimm_or_0_operand") + [(set (match_operand:VI_256_AVX2 0 "register_operand") + (vec_merge:VI_256_AVX2 + (match_operand:VI_256_AVX2 1 "nonimmediate_operand") + (match_operand:VI_256_AVX2 2 "nonimm_or_0_operand") (match_operand: 3 "register_operand")))] - "TARGET_AVX2" + "TARGET_AVX" { ix86_expand_sse_movcc (operands[0], operands[3], operands[1], operands[2]); --- gcc/testsuite/gcc.target/i386/avx-pr93637.c.jj 2020-02-10 13:19:18.2124= 37488 +0100 +++ gcc/testsuite/gcc.target/i386/avx-pr93637.c 2020-02-10 13:18:25.6512201= 71 +0100 @@ -0,0 +1,17 @@ +/* PR target/93637 */ +/* { dg-do compile } */ +/* { dg-options "-mavx -mno-avx2 -O3 --param sccvn-max-alias-queries-per-a= ccess=3D3" } */ + +double +foo (void) +{ + int i; + double r =3D 7.0; + double a[] =3D { 0.0, 0.0, -0.0, 0.0, 0.0, -0.0, 1.0, 0.0, 0.0, -0.0, 1.= 0, 0.0, 1.0, 1.0 }; + + for (i =3D 0; i < sizeof (a) / sizeof (a[0]); ++i) + if (a[i] =3D=3D 0.0) + r =3D a[i]; + + return r; +} Jakub