From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 99728 invoked by alias); 20 Mar 2018 10:08:17 -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 99716 invoked by uid 89); 20 Mar 2018 10:08:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,KAM_NUMSUBJECT,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Mar 2018 10:08:15 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 20E76ADE2 for ; Tue, 20 Mar 2018 10:08:13 +0000 (UTC) Date: Tue, 20 Mar 2018 10:35:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Jan Hubicka Subject: [PATCH] Fix PR84986 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SW-Source: 2018-03/txt/msg00933.txt.bz2 With the x86 vectorizer cost-model rewrite we ended up costing scalar conversions as nothing. After my patch using the proper target cost estimates for the scalar version this now exposes underestimating scalar cost and thus no longer vectorizing the testcase in this PR. This fix is to restrict zero-costing to sign-conversions, all other conversions are possibly value-changing. I guess some zero-extensions are free as well but I didn't want to get too fancy as I'm not sure about QImode -> SImode conversions for example since whether that's free (can just use %eax instead of %ax) likely depends on context. Bootstrap and regtest running on x86_64-unknown-linux-gnu. OK? Thanks, Richard. 2018-03-20 Richard Biener PR target/84986 * config/i386/i386.c (ix86_add_stmt_cost): Only cost sign-conversions as zero, fall back to standard scalar_stmt cost for the rest. * gcc.dg/vect/costmodel/x86_64/costmodel-pr84986.c: New testcase. Index: gcc/config/i386/i386.c =================================================================== --- gcc/config/i386/i386.c (revision 258674) +++ gcc/config/i386/i386.c (working copy) @@ -50462,7 +50462,11 @@ ix86_add_stmt_cost (void *data, int coun } break; case NOP_EXPR: - stmt_cost = 0; + /* Only sign-conversions are free. */ + if (tree_nop_conversion_p + (TREE_TYPE (gimple_assign_lhs (stmt_info->stmt)), + TREE_TYPE (gimple_assign_rhs1 (stmt_info->stmt)))) + stmt_cost = 0; break; case BIT_IOR_EXPR: Index: gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr84986.c =================================================================== --- gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr84986.c (nonexistent) +++ gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr84986.c (working copy) @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_long } */ + +int N; +long fn1(void) { + short i; + long a; + i = a = 0; + while (i < N) + a -= i++; + return a; +} + +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */