From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 40162 invoked by alias); 7 Sep 2019 09:56:41 -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 40150 invoked by uid 89); 7 Sep 2019 09:56:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=regtest, sk:tree_in X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 07 Sep 2019 09:56:39 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4AB1B3084242 for ; Sat, 7 Sep 2019 09:56:38 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E9A2C5C1B2 for ; Sat, 7 Sep 2019 09:56:37 +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 x879uZZi015717 for ; Sat, 7 Sep 2019 11:56:35 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id x879uYTO015716 for gcc-patches@gcc.gnu.org; Sat, 7 Sep 2019 11:56:34 +0200 Date: Sat, 07 Sep 2019 09:56:00 -0000 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Punt on vectorizing sign-changing conditional reduction (PR tree-optimization/91665) Message-ID: <20190907095634.GL2120@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.11.3 (2019-02-01) X-IsSubscribed: yes X-SW-Source: 2019-09/txt/msg00442.txt.bz2 Hi! We ICE on the following testcase, because we don't handle conditional expression where base has incompatible type (the iv bumped in unsigned type, but is signed otherwise, as happens for C/C++ signed char/short). This patch just punts on it, during x86_64-linux and i686-linux bootstrap/regtest it made a difference only on the testcase added by the patch. Preapproved by Richi on IRC, committed to trunk so far, queued for backporting. 2019-09-07 Jakub Jelinek PR tree-optimization/91665 * tree-vect-loop.c (vectorizable_reduction): Punt if base has type incompatible with the type of PHI result. * gcc.dg/vect/pr91665.c: New test. --- gcc/tree-vect-loop.c.jj 2019-09-05 15:29:20.570627230 +0200 +++ gcc/tree-vect-loop.c 2019-09-06 19:39:18.777405377 +0200 @@ -6656,10 +6656,13 @@ vectorizable_reduction (stmt_vec_info st gcc_assert (TREE_CODE (base) == INTEGER_CST && TREE_CODE (step) == INTEGER_CST); cond_reduc_val = NULL_TREE; + tree res = PHI_RESULT (STMT_VINFO_STMT (cond_stmt_vinfo)); + if (!types_compatible_p (TREE_TYPE (res), TREE_TYPE (base))) + ; /* Find a suitable value, for MAX_EXPR below base, for MIN_EXPR above base; punt if base is the minimum value of the type for MAX_EXPR or maximum value of the type for MIN_EXPR for now. */ - if (tree_int_cst_sgn (step) == -1) + else if (tree_int_cst_sgn (step) == -1) { cond_reduc_op_code = MIN_EXPR; if (tree_int_cst_sgn (base) == -1) --- gcc/testsuite/gcc.dg/vect/pr91665.c.jj 2019-09-05 14:20:01.986459651 +0200 +++ gcc/testsuite/gcc.dg/vect/pr91665.c 2019-09-05 13:54:52.944132072 +0200 @@ -0,0 +1,15 @@ +/* PR tree-optimization/91665 */ +/* { dg-do compile } */ +/* { dg-additional-options "-Ofast" } */ + +short int v; + +void +foo (short int x, short int y) +{ + short int *p = &v; + + x = 1; + while (x != 0) + x += ++y || (*p = x); +} Jakub