This is the mail archive of the gcc-patches@gcc.gnu.org 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]

Re: [PATCH v5, middle end]: Committed: Fix PR 37908, thinko with atomic NAND operation


On Thu, Nov 20, 2008 at 7:16 PM, Uros Bizjak <ubizjak@gmail.com> wrote:

>> I tried the patch here on IA64 Linux and HP-UX and it fixed these bugs
>> with no regressions.  Uros and Jakub, do one of you want to check in
>> the change or would you like me to?

2008-11-21  Uros Bizjak  <ubizjak@gmail.com>

	PR middle-end/37908
	* config/ia64/ia64.c (ia64_expand_atomic_ope): Properly handle NAND
	case by calculating ~(new_reg & val) instead of (~new_reg & val).
	* config/ia64/sync.md (sync_nand<mode>): Change insn RTX
	to (not:IMODE (and:IMODE (...))).
	(sync_old_nand<mode>): Ditto.
	(sync_new_nand<mode>): Ditto.

Attached patch was committed to SVN, compile tested with a crosscompiler.

Uros.

Index: ia64/sync.md
===================================================================
--- ia64/sync.md        (revision 142081)
+++ ia64/sync.md        (working copy)
@@ -57,8 +57,9 @@

 (define_expand "sync_nand<mode>"
   [(set (match_operand:IMODE 0 "memory_operand" "")
-       (and:IMODE (not:IMODE (match_dup 0))
-         (match_operand:IMODE 1 "general_operand" "")))]
+       (not:IMODE
+         (and:IMODE (match_dup 0)
+                    (match_operand:IMODE 1 "general_operand" ""))))]
   ""
 {
   ia64_expand_atomic_op (NOT, operands[0], operands[1], NULL, NULL);
@@ -78,9 +79,9 @@

 (define_expand "sync_old_nand<mode>"
   [(set (match_operand:IMODE 0 "gr_register_operand" "")
-       (and:IMODE
-         (not:IMODE (match_operand:IMODE 1 "memory_operand" ""))
-         (match_operand:IMODE 2 "general_operand" "")))]
+       (not:IMODE
+         (and:IMODE (match_operand:IMODE 1 "memory_operand" "")
+                    (match_operand:IMODE 2 "general_operand" ""))))]
   ""
 {
   ia64_expand_atomic_op (NOT, operands[1], operands[2], operands[0], NULL);
@@ -100,9 +101,9 @@

 (define_expand "sync_new_nand<mode>"
   [(set (match_operand:IMODE 0 "gr_register_operand" "")
-       (and:IMODE
-         (not:IMODE (match_operand:IMODE 1 "memory_operand" ""))
-         (match_operand:IMODE 2 "general_operand" "")))]
+       (not:IMODE
+         (and:IMODE (match_operand:IMODE 1 "memory_operand" "")
+                    (match_operand:IMODE 2 "general_operand" ""))))]
   ""
 {
   ia64_expand_atomic_op (NOT, operands[1], operands[2], NULL, operands[0]);
Index: ia64/ia64.c
===================================================================
--- ia64/ia64.c (revision 142081)
+++ ia64/ia64.c (working copy)
@@ -2141,11 +2141,13 @@
   new_reg = cmp_reg;
   if (code == NOT)
     {
-      new_reg = expand_simple_unop (DImode, NOT, new_reg, NULL_RTX, true);
-      code = AND;
+      new_reg = expand_simple_binop (DImode, AND, new_reg, val, NULL_RTX,
+                                    true, OPTAB_DIRECT);
+      new_reg = expand_simple_unop (DImode, code, new_reg, NULL_RTX, true);
     }
-  new_reg = expand_simple_binop (DImode, code, new_reg, val, NULL_RTX,
-                                true, OPTAB_DIRECT);
+  else
+    new_reg = expand_simple_binop (DImode, code, new_reg, val, NULL_RTX,
+                                  true, OPTAB_DIRECT);

   if (mode != DImode)
     new_reg = gen_lowpart (mode, new_reg);


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