From patchwork Mon Jan 7 23:26:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 210267 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 6136F2C0079 for ; Tue, 8 Jan 2013 10:27:01 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1358206022; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:User-Agent:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=fItoRxMIA6Mj7TxUTY/Ow5hHM1I=; b=N3voFWMQxTV2grm XSf2L/tM5WbMtaleCmxixNejo8Cj66hMqPY/J2aZsIPYKtti16hE73/MCmo0qdvl Qm4WuCOQdjAXlGFkMNHjA1UrOoGn52lRxx+93xsuD5M72V6aiZOEGCzpdFJ8tL9S qt7X4udtUAWFXnCUlVFUxkwGpSDE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=XMMxaH3kaQ5l9aPrux0Q2bmYakPSKAnVAecwydYshDKZsLDkZUL3A5JgzWU2lC lWTsx3deWsnFd0nqJvnatMT/R1UNlMbO8NzCYne96wy3pH9CYEBektqJr2czuYKL XEQVv1iOt5fWzNyyqQ0BqY/mJsaebLlFZLEJnMTF2ie9I=; Received: (qmail 30544 invoked by alias); 7 Jan 2013 23:26:55 -0000 Received: (qmail 30524 invoked by uid 22791); 7 Jan 2013 23:26:54 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_AV, TW_VZ, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 07 Jan 2013 23:26:42 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r07NQdr5007383 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 7 Jan 2013 18:26:39 -0500 Received: from zalov.redhat.com (vpn1-4-27.ams2.redhat.com [10.36.4.27]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r07NQaSC030370 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Jan 2013 18:26:38 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id r07NQZcf023915; Tue, 8 Jan 2013 00:26:35 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r07NQYer023914; Tue, 8 Jan 2013 00:26:34 +0100 Date: Tue, 8 Jan 2013 00:26:34 +0100 From: Jakub Jelinek To: Uros Bizjak , Richard Henderson Cc: Paolo Bonzini , gcc-patches@gcc.gnu.org, Vladimir Yakovlev , "Kumar, Venkataramanan" , Eric Botcazou Subject: Re: [PATCH, dataflow]: Fix PR55845, 454.calculix miscompares on x86 AVX due to movement of vzeroupper Message-ID: <20130107232634.GI7269@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <20130106162251.GX7269@tucnak.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 On Mon, Jan 07, 2013 at 05:52:23PM +0100, Uros Bizjak wrote: > TBH, I'm not that familiar with the RTL infrastructure enough to > answer these questions. While I can spend some time on this problem, > and probably waste quite some reviewer's time, the problem is not that > trivial as I hoped to be, so I would kindly ask someone with better > understanding of this part of the compiler for the proper solution. After discussion with rth on IRC, this modified patch just uses volatile_insn_p, making all UNSPEC_VOLATILE (wherever in insn) and asm volatile into a complete scheduling barrier for optimizations that use this function. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2012-01-08 Jakub Jelinek Uros Bizjak PR rtl-optimization/55845 * df-problems.c (can_move_insns_across): Stop scanning at volatile_insn_p source instruction or give up if across_from .. across_to range contains any volatile_insn_p instructions. 2012-01-08 Uros Bizjak Vladimir Yakovlev PR rtl-optimization/55845 * gcc.target/i386/pr55845.c: New test. Jakub --- gcc/df-problems.c.jj 2012-11-19 14:41:26.181898964 +0100 +++ gcc/df-problems.c 2013-01-07 18:38:33.064974313 +0100 @@ -3858,6 +3858,8 @@ can_move_insns_across (rtx from, rtx to, } if (NONDEBUG_INSN_P (insn)) { + if (volatile_insn_p (PATTERN (insn))) + return false; memrefs_in_across |= for_each_rtx (&PATTERN (insn), find_memory, NULL); note_stores (PATTERN (insn), find_memory_stores, @@ -3917,7 +3919,9 @@ can_move_insns_across (rtx from, rtx to, if (NONDEBUG_INSN_P (insn)) { if (may_trap_or_fault_p (PATTERN (insn)) - && (trapping_insns_in_across || other_branch_live != NULL)) + && (trapping_insns_in_across + || other_branch_live != NULL + || volatile_insn_p (PATTERN (insn)))) break; /* We cannot move memory stores past each other, or move memory --- gcc/testsuite/gcc.target/i386/pr55845.c.jj 2013-01-07 18:30:19.168801389 +0100 +++ gcc/testsuite/gcc.target/i386/pr55845.c 2013-01-07 18:30:19.168801389 +0100 @@ -0,0 +1,39 @@ +/* { dg-do run } */ +/* { dg-require-effective-target avx } */ +/* { dg-options "-O3 -ffast-math -fschedule-insns -mavx -mvzeroupper" } */ + +#include "avx-check.h" + +#define N 100 + +double +__attribute__((noinline)) +foo (int size, double y[], double x[]) +{ + double sum = 0.0; + int i; + for (i = 0, sum = 0.; i < size; i++) + sum += y[i] * x[i]; + return (sum); +} + +static void +__attribute__ ((noinline)) +avx_test () +{ + double x[N]; + double y[N]; + double s; + int i; + + for (i = 0; i < N; i++) + { + x[i] = i; + y[i] = i; + } + + s = foo (N, y, x); + + if (s != 328350.0) + abort (); +}