From patchwork Tue May 22 09:54:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 918128 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-478148-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="SCY6o16+"; 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 40qrbx0g9Rz9s3T for ; Tue, 22 May 2018 19:55:08 +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:subject:message-id:mime-version:content-type; q=dns; s= default; b=hrr8TJG7a/1KZNDJdjyFECXMpIwVe1DOg9ODU2Gw+4dQbZGzI8OKF 4u/a0/Al5M6oq3xzCb9Rspeb35hKrDIQtPZVDFE5V10HqHth97YICn69ofi013zG ccPcd+eTCpnyXSM7lLbmjsa1BEL6d6MK1X2+SgmOuR+cbqA0xiuW2M= 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=N16iXDET2+2br9ohEEIc4nfDBBk=; b=SCY6o16+UPKalId6xEiE +8ZW3UB/NUvdSQXd3QLo30JEI7EFwpx66fipC7Jnz7Fg4Op+Vi0YTFwj433NjawK a6sk9jr8fafDZjR0+5QM5mPCPL4ESu972ss0Lc2oXIfvzuUcoKyC5fIQ7gqPMka1 Fd+ZTGtR0VBA32zjSp0zMcQ= Received: (qmail 86231 invoked by alias); 22 May 2018 09:55:00 -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 86209 invoked by uid 89); 22 May 2018 09:54:59 -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 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, 22 May 2018 09:54:57 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BC29EABB4 for ; Tue, 22 May 2018 09:54:55 +0000 (UTC) Date: Tue, 22 May 2018 11:54:55 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR85863 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 The following fixes mishandling of widening invariant comparisons in vect_is_simple_cond which isn't supported for SLP code generation. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk, queued for backports. Richard. 2018-05-22 Richard Biener PR tree-optimization/85863 * tree-vect-stmts.c (vect_is_simple_cond): Only widen invariant comparisons when vectype is specified. (vectorizable_condition): Do not specify vectype for vect_is_simple_cond when SLP vectorizing. * gfortran.fortran-torture/compile/pr85863.f: New testcase. Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c (revision 260499) +++ gcc/tree-vect-stmts.c (working copy) @@ -8661,7 +8661,7 @@ vect_is_simple_cond (tree cond, vec_info *comp_vectype = vectype1 ? vectype1 : vectype2; /* Invariant comparison. */ - if (! *comp_vectype) + if (! *comp_vectype && vectype) { tree scalar_type = TREE_TYPE (lhs); /* If we can widen the comparison to match vectype do so. */ @@ -8773,7 +8773,7 @@ vectorizable_condition (gimple *stmt, gi else_clause = gimple_assign_rhs3 (stmt); if (!vect_is_simple_cond (cond_expr, stmt_info->vinfo, - &comp_vectype, &dts[0], vectype) + &comp_vectype, &dts[0], slp_node ? NULL : vectype) || !comp_vectype) return false; Index: gcc/testsuite/gfortran.fortran-torture/compile/pr85863.f =================================================================== --- gcc/testsuite/gfortran.fortran-torture/compile/pr85863.f (nonexistent) +++ gcc/testsuite/gfortran.fortran-torture/compile/pr85863.f (working copy) @@ -0,0 +1,22 @@ +! { dg-do compile } +! { dg-additional-options "-ffast-math -ftree-vectorize" } + SUBROUTINE SOBOOK(MHSO,HSOMAX,MS) + IMPLICIT DOUBLE PRECISION(A-H,O-Z) + COMPLEX*16 HSOT,HSO1(2) + PARAMETER (ZERO=0.0D+00,TWO=2.0D+00) + DIMENSION SOL1(3,2),SOL2(3) + CALL FOO(SOL1,SOL2) + SQRT2=SQRT(TWO) + DO IH=1,MHSO + IF(MS.EQ.0) THEN + HSO1(IH) = DCMPLX(ZERO,-SOL1(3,IH)) + HSOT = DCMPLX(ZERO,-SOL2(3)) + ELSE + HSO1(IH) = DCMPLX(-SOL1(2,IH),SOL1(1,IH))/SQRT2 + HSOT = DCMPLX(-SOL2(2),SOL2(1))/SQRT2 + ENDIF + ENDDO + HSOT=HSOT+HSO1(1) + HSOMAX=MAX(HSOMAX,ABS(HSOT)) + RETURN + END