From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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: Mon, 07 Jan 2013 23:26:00 -0000 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-Type: text/plain; charset=us-ascii 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg00374.txt.bz2 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. --- 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 (); +} Jakub