From patchwork Mon Aug 16 22:35:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 61845 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 5134BB70B8 for ; Tue, 17 Aug 2010 08:36:05 +1000 (EST) Received: (qmail 27869 invoked by alias); 16 Aug 2010 22:36:03 -0000 Received: (qmail 27861 invoked by uid 22791); 16 Aug 2010 22:36:03 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-bw0-f47.google.com (HELO mail-bw0-f47.google.com) (209.85.214.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 16 Aug 2010 22:35:58 +0000 Received: by bwz12 with SMTP id 12so2509643bwz.20 for ; Mon, 16 Aug 2010 15:35:56 -0700 (PDT) Received: by 10.204.100.204 with SMTP id z12mr3754568bkn.194.1281998156284; Mon, 16 Aug 2010 15:35:56 -0700 (PDT) Received: from yakj.usersys.redhat.com (s209p8.home.99maxprogres.cz [85.93.118.17]) by mx.google.com with ESMTPS id s34sm4678433bkk.13.2010.08.16.15.35.54 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 16 Aug 2010 15:35:55 -0700 (PDT) Message-ID: <4C69BD49.9040209@gnu.org> Date: Tue, 17 Aug 2010 00:35:53 +0200 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100621 Fedora/3.0.5-1.fc13 Lightning/1.0b2pre Mnenhy/0.8.3 Thunderbird/3.0.5 MIME-Version: 1.0 To: GCC Patches Subject: fix PR/45292, miscompilation of sync_bool_compare_and_swap due to deferred pop 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 This fixes a bug in expansion of sync_bool_compare_and_swap, where we were relying on the CC value from the sync_compare_and_swap optab but clobbering it before reading it. This is due to a do_pending_stack_adjust in emit_store_flag_1. Fixed by doing the stack adjust before everything else. This is a regression from 4.4. The testcase is libgomp; bootstrapped/regtested x86_64-pc-linux-gnu, checked the problematic file using -march=i486 -mtune=i586. Ok for 4.5 and trunk? Paolo 2010-08-17 Paolo Bonzini * optabs.c (expand_bool_compare_and_swap): Expand pending pops before trying the optab. Index: optabs.c =================================================================== --- optabs.c (revision 162940) +++ optabs.c (working copy) @@ -6909,6 +6909,7 @@ expand_bool_compare_and_swap (rtx mem, r if (icode == CODE_FOR_nothing) return NULL_RTX; + do_pending_stack_adjust (); do { start_sequence ();