]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR target/28909 (Missed optimization with x86 sync builtins)
authorUros Bizjak <uros@kss-loka.si>
Wed, 25 Oct 2006 10:14:41 +0000 (12:14 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Wed, 25 Oct 2006 10:14:41 +0000 (12:14 +0200)
        PR target/28909
        * config/i386/sync.md ("sync_add<mode>", "sync_sub<mode>"):
        Use inc and dec instructions for TARGET_USE_INCDEC.
        ("*sync_compare_and_swap<mode>"): Fix -masm=intel template.
        ("sync_double_compare_and_swap<mode>"): Likewise.
        ("*sync_double_compare_and_swapdi_pic"): Likewise.
        ("*sync_compare_and_swap_cc<mode>"): Likewise.
        ("sync_double_compare_and_swap_cc<mode>"): Likewise.
        ("*sync_double_compare_and_swap_ccdi_pic"): Likewise.
        ("sync_old_add<mode>"): Likewise.
        ("sync_lock_test_and_set<mode>"): Likewise.
        ("sync_lock_test_and_set<mode>"): Likewise.
        ("sync_add<mode>"): Likewise.
        ("sync_sub<mode>"): Likewise.
        ("sync_ior<mode>"): Likewise.
        ("sync_and<mode>"): Likewise.
        ("sync_xor<mode>"): Likewise.

From-SVN: r118028

gcc/ChangeLog
gcc/config/i386/sync.md

index 905863120330910345d3f9952b726357a4bede5f..a4ffc2d9eb336a0556508beff6d2d80f6036722c 100644 (file)
@@ -1,3 +1,23 @@
+2006-10-25  Uros Bizjak  <uros@kss-loka.si>
+
+       PR target/28909
+       * config/i386/sync.md ("sync_add<mode>", "sync_sub<mode>"):
+       Use inc and dec instructions for TARGET_USE_INCDEC.
+       ("*sync_compare_and_swap<mode>"): Fix -masm=intel template.
+       ("sync_double_compare_and_swap<mode>"): Likewise.
+       ("*sync_double_compare_and_swapdi_pic"): Likewise.
+       ("*sync_compare_and_swap_cc<mode>"): Likewise.
+       ("sync_double_compare_and_swap_cc<mode>"): Likewise.
+       ("*sync_double_compare_and_swap_ccdi_pic"): Likewise.
+       ("sync_old_add<mode>"): Likewise.
+       ("sync_lock_test_and_set<mode>"): Likewise.
+       ("sync_lock_test_and_set<mode>"): Likewise.
+       ("sync_add<mode>"): Likewise.
+       ("sync_sub<mode>"): Likewise.
+       ("sync_ior<mode>"): Likewise.
+       ("sync_and<mode>"): Likewise.
+       ("sync_xor<mode>"): Likewise.
+
 2006-10-25  Uros Bizjak  <uros@kss-loka.si>
 
        * optabs.h (enum optab_index): Rename OTI_drem to OTI_remainder.
index 489de1914d234f7d3b0da23a99f9c014ff45876c..58e047bc23484206720de512c252c84410053ad4 100644 (file)
@@ -82,7 +82,7 @@
          UNSPECV_CMPXCHG_1))
    (clobber (reg:CC FLAGS_REG))]
   "TARGET_CMPXCHG"
-  "lock\;cmpxchg{<modesuffix>}\t{%3, %1|%1, %3}")
+  "lock{\;| }cmpxchg{<modesuffix>\t%3, %1| %1, %3}")
 
 (define_insn "sync_double_compare_and_swap<mode>"
   [(set (match_operand:DCASMODE 0 "register_operand" "=A")
@@ -96,7 +96,7 @@
          UNSPECV_CMPXCHG_1))
    (clobber (reg:CC FLAGS_REG))]
   ""
-  "lock\;cmpxchg<doublemodesuffix>b\t%1")
+  "lock{\;| }cmpxchg<doublemodesuffix>b{\t| }%1")
 
 (define_insn "*sync_double_compare_and_swapdi_pic"
   [(set (match_operand:DI 0 "register_operand" "=A")
          UNSPECV_CMPXCHG_1))
    (clobber (reg:CC FLAGS_REG))]
   "!TARGET_64BIT && TARGET_CMPXCHG8B && flag_pic"
-  "xchg{l}\t%%ebx, %3\;lock\;cmpxchg8b\t%1\;xchg{l}\t%%ebx, %3")
+  "xchg{l}\t%%ebx, %3\;lock{\;| }cmpxchg8b{\t| }%1\;xchg{l}\t%%ebx, %3")
 
 (define_expand "sync_compare_and_swap_cc<mode>"
   [(parallel
            [(match_dup 1) (match_dup 2) (match_dup 3)] UNSPECV_CMPXCHG_2)
          (match_dup 2)))]
   "TARGET_CMPXCHG"
-  "lock\;cmpxchg{<modesuffix>}\t{%3, %1|%1, %3}")
+  "lock{\;| }cmpxchg{<modesuffix>\t%3, %1| %1, %3}")
 
 (define_insn "sync_double_compare_and_swap_cc<mode>"
   [(set (match_operand:DCASMODE 0 "register_operand" "=A")
            UNSPECV_CMPXCHG_2)
          (match_dup 2)))]
   ""
-  "lock\;cmpxchg<doublemodesuffix>b\t%1")
+  "lock{\;| }cmpxchg<doublemodesuffix>b{\t| }%1")
 
 (define_insn "*sync_double_compare_and_swap_ccdi_pic"
   [(set (match_operand:DI 0 "register_operand" "=A")
            UNSPECV_CMPXCHG_2)
          (match_dup 2)))]
   "!TARGET_64BIT && TARGET_CMPXCHG8B && flag_pic"
-  "xchg{l}\t%%ebx, %3\;lock\;cmpxchg8b\t%1\;xchg{l}\t%%ebx, %3")
+  "xchg{l}\t%%ebx, %3\;lock{\;| }cmpxchg8b{\t| }%1\;xchg{l}\t%%ebx, %3")
 
 (define_insn "sync_old_add<mode>"
   [(set (match_operand:IMODE 0 "register_operand" "=<modeconstraint>")
                    (match_operand:IMODE 2 "register_operand" "0")))
    (clobber (reg:CC FLAGS_REG))]
   "TARGET_XADD"
-  "lock\;xadd{<modesuffix>}\t{%0, %1|%1, %0}")
+  "lock{\;| }xadd{<modesuffix>\t%0, %1| %1, %0}")
 
 ;; Recall that xchg implicitly sets LOCK#, so adding it again wastes space.
 (define_insn "sync_lock_test_and_set<mode>"
          UNSPECV_LOCK))
    (clobber (reg:CC FLAGS_REG))]
   ""
-  "lock\;add{<modesuffix>}\t{%1, %0|%0, %1}")
+{
+  if (TARGET_USE_INCDEC)
+    {
+      if (operands[1] == const1_rtx)
+       return "lock{\;| }inc{<modesuffix>\t| }%0";
+      if (operands[1] == constm1_rtx)
+       return "lock{\;| }dec{<modesuffix>\t| }%0";
+    }
+
+  return "lock{\;| }add{<modesuffix>\t%1, %0| %0, %1}";
+})
 
 (define_insn "sync_sub<mode>"
   [(set (match_operand:IMODE 0 "memory_operand" "+m")
          UNSPECV_LOCK))
    (clobber (reg:CC FLAGS_REG))]
   ""
-  "lock\;sub{<modesuffix>}\t{%1, %0|%0, %1}")
+{
+  if (TARGET_USE_INCDEC)
+    {
+      if (operands[1] == const1_rtx)
+       return "lock{\;| }dec{<modesuffix>\t| }%0";
+      if (operands[1] == constm1_rtx)
+       return "lock{\;| }inc{<modesuffix>\t| }%0";
+    }
+
+  return "lock{\;| }sub{<modesuffix>\t%1, %0| %0, %1}";
+})
 
 (define_insn "sync_ior<mode>"
   [(set (match_operand:IMODE 0 "memory_operand" "+m")
          UNSPECV_LOCK))
    (clobber (reg:CC FLAGS_REG))]
   ""
-  "lock\;or{<modesuffix>}\t{%1, %0|%0, %1}")
+  "lock{\;| }or{<modesuffix>\t%1, %0| %0, %1}")
 
 (define_insn "sync_and<mode>"
   [(set (match_operand:IMODE 0 "memory_operand" "+m")
          UNSPECV_LOCK))
    (clobber (reg:CC FLAGS_REG))]
   ""
-  "lock\;and{<modesuffix>}\t{%1, %0|%0, %1}")
+  "lock{\;| }and{<modesuffix>\t%1, %0| %0, %1}")
 
 (define_insn "sync_xor<mode>"
   [(set (match_operand:IMODE 0 "memory_operand" "+m")
          UNSPECV_LOCK))
    (clobber (reg:CC FLAGS_REG))]
   ""
-  "lock\;xor{<modesuffix>}\t{%1, %0|%0, %1}")
+  "lock{\;| }xor{<modesuffix>\t%1, %0| %0, %1}")