OSDN Git Service

* optabs.c (expand_unop): Try implementing negation using subtraction
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 May 2004 06:50:51 +0000 (06:50 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 May 2004 06:50:51 +0000 (06:50 +0000)
from zero.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@81933 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/optabs.c

index cabd0f3..80bbf2a 100644 (file)
@@ -1,3 +1,8 @@
+2004-05-17  Richard Sandiford  <rsandifo@redhat.com>
+
+       * optabs.c (expand_unop): Try implementing negation using subtraction
+       from zero.
+
 2004-05-16  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        * pa.md:  Fix typo from last change.  Remove DFmode move to and from
index f89e053..562eb29 100644 (file)
@@ -2737,6 +2737,15 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target,
        return temp;
     }
 
+  /* If there is no negation pattern, try subtracting from zero.  */
+  if (unoptab == neg_optab && class == MODE_INT)
+    {
+      temp = expand_binop (mode, sub_optab, CONST0_RTX (mode), op0,
+                           target, unsignedp, OPTAB_DIRECT);
+      if (temp)
+       return temp;
+    }
+
  try_libcall:
   /* Now try a library call in this mode.  */
   if (unoptab->handlers[(int) mode].libfunc)