From patchwork Sun Jan 6 15:48:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 209778 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 579CF2C0084 for ; Mon, 7 Jan 2013 02:48:16 +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=1358092097; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=IE9Ylra 1iDO1m3dWjE2IcbtLelc=; b=WI7N09Rbvn7qvGDaEEexYUcRGdxaywt68+Kcu63 flmoau3w7eoWsuxaZAQMJqw/qvUQz9DDJsgJTT7JQGxU98z90FaXwAc7Kp8WN/Dl JKkjKM7QyH5UPOX3JlXw2ZThbU+sEyS0ZtZgGd91w8xSThCd77cgjUJ2xLyZzZPe yJQ8= 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:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=hrYvxUEzZiXf/nn9Nr29QzS19d/qhdHbYlO7fQXZafFyGi7Dqfou8/H5R3GtPv 1zY93g2JwUqNUe6msQEWqBVvpucnkNp9GFM2rUiYK8RVnnqXz4erPFqxSA/DcuHG FzWAgoE2psFNwCxHDY/XGtkL6Dikk3a7iSNc5XnmUQN0w=; Received: (qmail 13463 invoked by alias); 6 Jan 2013 15:48:10 -0000 Received: (qmail 13454 invoked by uid 22791); 6 Jan 2013 15:48:08 -0000 X-SWARE-Spam-Status: No, hits=-4.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_AV, TW_VZ, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-oa0-f54.google.com (HELO mail-oa0-f54.google.com) (209.85.219.54) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 06 Jan 2013 15:48:03 +0000 Received: by mail-oa0-f54.google.com with SMTP id n9so16668142oag.27 for ; Sun, 06 Jan 2013 07:48:03 -0800 (PST) MIME-Version: 1.0 Received: by 10.60.32.235 with SMTP id m11mr33649611oei.129.1357487283368; Sun, 06 Jan 2013 07:48:03 -0800 (PST) Received: by 10.182.153.201 with HTTP; Sun, 6 Jan 2013 07:48:03 -0800 (PST) Date: Sun, 6 Jan 2013 16:48:03 +0100 Message-ID: Subject: [PATCH, dataflow]: Fix PR55845, 454.calculix miscompares on x86 AVX due to movement of vzeroupper From: Uros Bizjak To: gcc-patches@gcc.gnu.org Cc: Vladimir Yakovlev , "Kumar, Venkataramanan" 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 Hello! Attached patch fixes runtime comparison failure of 454.calculix due to wrong movement of vzeroupper in jump2 pass. It turns out, that can_move_insns_accross function does not special-case unspec_volatiles, so vzeroupper is allowed to pass various 256bit avx instructions. The patch rejects moves of unspec_volatile insns in can_move_insn_accross. 2012-01-06 Uros Bizjak PR rtl-optimization/55845 * df-problems.c (can_move_insns_across): Stop scanning at unspec_volatile source instruction. 2012-01-06 Uros Bizjak Vladimir Yakovlev PR rtl-optimization/55845 * gcc.target/i386/pr55845.c: New test. Bootstrapped and regression tested on x86_64-pc-linux-gnu {,-m32} AVX target. OK for mainline and 4.7 branch? Uros. Index: df-problems.c =================================================================== --- df-problems.c (revision 194945) +++ df-problems.c (working copy) @@ -3916,6 +3916,10 @@ can_move_insns_across (rtx from, rtx to, rtx acros break; if (NONDEBUG_INSN_P (insn)) { + /* Do not move unspec_volatile insns. */ + if (GET_CODE (PATTERN (insn)) == UNSPEC_VOLATILE) + break; + if (may_trap_or_fault_p (PATTERN (insn)) && (trapping_insns_in_across || other_branch_live != NULL)) break; Index: testsuite/gcc.target/i386/pr55845.c =================================================================== --- testsuite/gcc.target/i386/pr55845.c (revision 0) +++ testsuite/gcc.target/i386/pr55845.c (working copy) @@ -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 (); +}