From patchwork Mon Aug 16 22:35:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: fix PR/45292, miscompilation of sync_bool_compare_and_swap due to deferred pop Date: Mon, 16 Aug 2010 12:35:53 -0000 From: Paolo Bonzini X-Patchwork-Id: 61845 Message-Id: <4C69BD49.9040209@gnu.org> To: GCC Patches 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 ();