]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/11210 (optimizer drops conditional with typecast from signed...
authorEric Botcazou <ebotcazou@libertysurf.fr>
Thu, 26 Jun 2003 10:37:35 +0000 (12:37 +0200)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Thu, 26 Jun 2003 10:37:35 +0000 (10:37 +0000)
PR optimization/11210
* fold-const (decode_field_reference): Strip only NOPs that
don't affect the sign.

From-SVN: r68524

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/20030626-1.c [new file with mode: 0644]

index e92b4a51933a458ce192ac2373e15aa1a56ef405..fec3aeaadc902927dfb9031fdb29fb234ab13ee2 100644 (file)
@@ -1,3 +1,9 @@
+2003-06-26  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       PR optimization/11210
+       * fold-const (decode_field_reference): Strip only NOPs that
+       don't affect the sign.
+
 2003-06-26  Dhananjay Deshpande  <dhananjayd@kpitcummins.com>
 
        * gcc/config/sh/sh.md (push_fpscr): Enable for TARGET_SH2E.
index b35d733e220c6cc6d10d047b8a944dbfc968c1d4..b160a4ea0ebe76cd187f174ef6911e092303d7fd 100644 (file)
@@ -2742,7 +2742,8 @@ decode_field_reference (exp, pbitsize, pbitpos, pmode, punsignedp,
   if (! INTEGRAL_TYPE_P (TREE_TYPE (exp)))
     return 0;
 
-  STRIP_NOPS (exp);
+  /* Signedness matters here.  */
+  STRIP_SIGN_NOPS (exp);
 
   if (TREE_CODE (exp) == BIT_AND_EXPR)
     {
index e5f954145af693a9de9a6715cb2907b7870efc18..c988401302d2d7a2973ed511ffe6f5e3a1cf203c 100644 (file)
@@ -1,3 +1,7 @@
+2003-06-26  Eric Botcazou <ebotcazou@libertysurf.fr>
+
+       * gcc.dg/20030626-1.c: New test.
+
 2003-06-26  Neil Booth  <neil@daikokuya.co.uk>
 
        * const-str-2.m: Update.
diff --git a/gcc/testsuite/gcc.dg/20030626-1.c b/gcc/testsuite/gcc.dg/20030626-1.c
new file mode 100644 (file)
index 0000000..7d356e0
--- /dev/null
@@ -0,0 +1,18 @@
+/* PR optimization/11210 */
+/* Originator: Guido Classen <guido@clagi.de> */
+/* Reduced testcase by Falk Hueffner <falk@debian.org> */
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+/* Verify that the constant expressions folder doesn't
+   throw away the cast operation in the comparison.  */
+
+struct str { 
+  int head; 
+  char data[8];
+};
+
+int foo(struct str t)
+{
+  return t.data[0] || (unsigned char) t.data[2] != 130; /* { dg-bogus "comparison is always 1" } */
+}