This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] fix opt/14194
- From: Richard Henderson <rth at twiddle dot net>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 20 Feb 2004 10:54:49 -0800
- Subject: [tree-ssa] fix opt/14194
The deal is that __builtin_expect was seen to clobber "irqs", and
so by folding the function away, we need to rename the VDEFs.
I suppose I could do a more rigourous check for having folded away
a function call, but I'm not sure that's worthwhile...
r~
* tree-ssa-ccp.c (substitute_and_fold): Also mark new vars
if fold_stmt was successful.
Index: gcc/tree-ssa-ccp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-ccp.c,v
retrieving revision 1.1.2.140
diff -u -p -r1.1.2.140 tree-ssa-ccp.c
--- gcc/tree-ssa-ccp.c 17 Feb 2004 17:54:20 -0000 1.1.2.140
+++ gcc/tree-ssa-ccp.c 20 Feb 2004 18:48:17 -0000
@@ -384,10 +384,12 @@ substitute_and_fold (void)
if (replace_uses_in (stmt, &replaced_address))
{
- fold_stmt (bsi_stmt_ptr (i));
+ bool changed = fold_stmt (bsi_stmt_ptr (i));
stmt = bsi_stmt(i);
modify_stmt (stmt);
- if (replaced_address)
+ /* If we folded a builtin function, we'll likely
+ need to rename VDEFs. */
+ if (replaced_address || changed)
mark_new_vars_to_rename (stmt, vars_to_rename);
}
Index: gcc/testsuite/gcc.c-torture/20040420-1.c
===================================================================
RCS file: gcc/testsuite/gcc.c-torture/20040420-1.c
diff -N gcc/testsuite/gcc.c-torture/20040420-1.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/gcc.c-torture/20040420-1.c 20 Feb 2004 18:48:17 -0000
@@ -0,0 +1,16 @@
+/* PR 14194 */
+
+int irqs;
+
+static inline __attribute__((always_inline))
+int kstat_irqs (void) {
+ int i, sum = 0;
+ for (i = 0; i < 1; i++)
+ if (__builtin_expect(i, 0))
+ sum += irqs;
+ return sum;
+}
+
+int show_interrupts (void) {
+ return kstat_irqs ();
+}