re PR rtl-optimization/11557 (constant folding)
authorMark Mitchell <mark@codesourcery.com>
Fri, 18 Jul 2003 03:05:27 +0000 (03:05 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 18 Jul 2003 03:05:27 +0000 (03:05 +0000)
PR optimization/11557
* calls.c (flags_from_decl_or_type): Do not set ECF_LIBCALL_BLOCK
unless we know which function is being called.

PR optimization/11557
* gcc.dg/20030717-1.c: New test.

From-SVN: r69538

gcc/ChangeLog
gcc/calls.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/20030717-1.c [new file with mode: 0644]

index 3784190c92390033c4b0b884b9a18b61944b61e2..0fe5852478ad9b77e83731c6626b3f4370d99133 100644 (file)
@@ -1,3 +1,9 @@
+2003-07-17  Mark Mitchell  <mark@codesourcery.com>
+
+       PR optimization/11557
+       * calls.c (flags_from_decl_or_type): Do not set ECF_LIBCALL_BLOCK
+       unless we know which function is being called.
+
 2003-07-17  Roger Sayle  <roger@eyesopen.com>
 
        * cse.c (fold_rtx): Use swap_commutative_operands_p to determine
index ef4926ee77093b4aa338fb499af6cbec4bea4295..845934e2cb5446deb0c96d03cc1231c6a6f13e0d 100644 (file)
@@ -730,10 +730,13 @@ flags_from_decl_or_type (tree exp)
 
       if (TREE_NOTHROW (exp))
        flags |= ECF_NOTHROW;
+
+      if (TREE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp))
+       flags |= ECF_LIBCALL_BLOCK;
     }
 
   if (TREE_READONLY (exp) && ! TREE_THIS_VOLATILE (exp))
-    flags |= ECF_CONST | ECF_LIBCALL_BLOCK;
+    flags |= ECF_CONST;
 
   if (TREE_THIS_VOLATILE (exp))
     flags |= ECF_NORETURN;
index b0b3f4430d2c7e541cdb98c4434110d1261d8552..91f7815eaf33577148094c4259b74794d1aa98a7 100644 (file)
@@ -1,3 +1,8 @@
+2003-07-17  Mark Mitchell  <mark@codesourcery.com>
+
+       PR optimization/11557
+       * gcc.dg/20030717-1.c: New test.
+
 2003-07-17  Andrew Pinski <pinskia@physics.uc.edu>
 
        PR c++/10476
diff --git a/gcc/testsuite/gcc.dg/20030717-1.c b/gcc/testsuite/gcc.dg/20030717-1.c
new file mode 100644 (file)
index 0000000..6a7f6de
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+extern void abort (void);
+
+int zero (void)
+{
+  return 0;
+}
+
+int one (void)
+{
+  return 1;
+}
+
+int main (void)
+{
+  int i = 1;
+  int r = (i ? one : zero)();
+  if (r != 1)
+    abort();
+  return 0;
+}
+