This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch for PR libgomp/37938, IA64 specific.

Some libgomp tests were failing on IA64 Linux (but not HP-UX), the
problem was that Linux uses the sync_lock_test_and_set instruction and
this did not have a memory barrier in it to make sure that loads and
stores were completed before the sync_lock_test_and_set instruction was
executed.  This patch changes sync_lock_test_and_set to a define_expand
that has a memory barrier followed by the original xchg instruction (now
renamed to sync_lock_test_and_set_xchg).

Tested on IA64 Linux and HP-UX with no regressions.

I'll wait a day before checking the patch in to give people a chance to
look it over.

Steve Ellcey

2008-11-04  Steve Ellcey  <>

	PR libgomp/37938
	* config/ia64/ (sync_lock_test_and_set_xchg<mode>): New name
	for original sync_lock_test_and_set<mode>.
	(sync_lock_test_and_set<mode>): Create define_expand version.

Index: config/ia64/
--- config/ia64/	(revision 141574)
+++ config/ia64/	(working copy)
@@ -159,7 +159,20 @@ (define_insn "cmpxchg_rel_di"
   "cmpxchg8.rel %0 = %1, %3, %2"
   [(set_attr "itanium_class" "sem")])
-(define_insn "sync_lock_test_and_set<mode>"
+(define_expand "sync_lock_test_and_set<mode>"
+  [(set (match_operand:IMODE 0 "gr_register_operand" "")
+        (match_operand:IMODE 1 "not_postinc_memory_operand" ""))
+   (set (match_dup 1)
+        (match_operand:IMODE 2 "gr_register_operand" ""))]
+  ""
+  emit_insn (gen_memory_barrier ());
+  emit_insn (gen_sync_lock_test_and_set_xchg<mode> (operands[0], operands[1],
+	     operands[2]));
+  DONE;
+(define_insn "sync_lock_test_and_set_xchg<mode>"
   [(set (match_operand:IMODE 0 "gr_register_operand" "=r")
         (match_operand:IMODE 1 "not_postinc_memory_operand" "+S"))
    (set (match_dup 1)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]