simplify-rtx.c (simplify_binary_operation): Simplify ~a + 1 into -a.
authorLars Brinkhoff <lars@nocrew.org>
Sat, 5 May 2001 00:32:19 +0000 (00:32 +0000)
committerGeoffrey Keating <geoffk@gcc.gnu.org>
Sat, 5 May 2001 00:32:19 +0000 (00:32 +0000)
2001-05-04  Lars Brinkhoff  <lars@nocrew.org>

* simplify-rtx.c (simplify_binary_operation): Simplify ~a + 1
into -a.

From-SVN: r41854

gcc/ChangeLog
gcc/simplify-rtx.c

index 277e58f2e7bca21294962ae695f4dc94e39804ce..bc4f951b407806040afcdd07003acc6ef7935c58 100644 (file)
@@ -1,6 +1,12 @@
+2001-05-04  Lars Brinkhoff  <lars@nocrew.org>
+
+       * simplify-rtx.c (simplify_binary_operation): Simplify ~a + 1
+       into -a.
+
 2000-05-04  Franz Sirl  <Franz.Sirl-kernel@lauterbach.com>
 
-       * config/rs6000/rs6000.md (ashldi3 splits): Guard with TARGET_POWERPC64.
+       * config/rs6000/rs6000.md (ashldi3 splits): Guard with
+       TARGET_POWERPC64.
 
 2001-05-04  Stephane Carrez  <Stephane.Carrez@worldnet.fr>
 
index 07fb24ba9f0e87c1df31ef49e8b0915c0be4329e..046882002a50a7e7be49aef8a807ac93d8e59a90 100644 (file)
@@ -945,6 +945,13 @@ simplify_binary_operation (code, mode, op0, op1)
          else if (GET_CODE (op1) == NEG)
            return simplify_gen_binary (MINUS, mode, op0, XEXP (op1, 0));
 
+         /* (~a) + 1 -> -a */
+         if (INTEGRAL_MODE_P (mode)
+             && GET_CODE (op0) == NOT
+             && GET_CODE (op1) == CONST_INT
+             && INTVAL (op1) == 1)
+           return gen_rtx_NEG (mode, XEXP (op0, 0));
+
          /* Handle both-operands-constant cases.  We can only add
             CONST_INTs to constants since the sum of relocatable symbols
             can't be handled by most assemblers.  Don't add CONST_INT