PR middle-end/19551
* flow.c (libcall_dead_p): Be more conservative if unsure.
If there are any instructions between insn and call, see if they are
all dead before saying the libcall is dead.
* gcc.c-torture/execute/
20050121-1.c: New test.
* gcc.dg/
20050121-2.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@94145
138bc75d-0d04-0410-961f-
82ee72b054a4
+2005-01-24 Jakub Jelinek <jakub@redhat.com>
+
+ * flow.c (propagate_one_insn): Formatting.
+
+ PR middle-end/19551
+ * flow.c (libcall_dead_p): Be more conservative if unsure.
+ If there are any instructions between insn and call, see if they are
+ all dead before saying the libcall is dead.
+
2005-01-24 Uros Bizjak <uros@kss-loka.si>
* config/i386/i386.md (*extendsfdf2_sse): Use "nonimmediate_operand"
pbi->cc0_live = 0;
if (libcall_is_dead)
- prev = propagate_block_delete_libcall ( insn, note);
+ prev = propagate_block_delete_libcall (insn, note);
else
{
{
rtx r = SET_SRC (x);
- if (REG_P (r))
+ if (REG_P (r) || GET_CODE (r) == SUBREG)
{
rtx call = XEXP (note, 0);
rtx call_pat;
call_pat = XVECEXP (call_pat, 0, i);
}
- return insn_dead_p (pbi, call_pat, 1, REG_NOTES (call));
+ if (! insn_dead_p (pbi, call_pat, 1, REG_NOTES (call)))
+ return 0;
+
+ while ((insn = PREV_INSN (insn)) != call)
+ {
+ if (! INSN_P (insn))
+ continue;
+ if (! insn_dead_p (pbi, PATTERN (insn), 0, REG_NOTES (insn)))
+ return 0;
+ }
+ return 1;
}
}
- return 1;
+ return 0;
}
/* 1 if register REGNO was alive at a place where `setjmp' was called
+2005-01-24 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/19551
+ * gcc.c-torture/execute/20050121-1.c: New test.
+ * gcc.dg/20050121-2.c: New test.
+
2004-01-23 Steven G. Kargl <kargls@comcast.net>
Paul Brook <paul@codesourcery.com>
--- /dev/null
+/* PR middle-end/19551 */
+
+extern void abort ();
+
+#define T(type, name) \
+__attribute__((pure)) _Complex type \
+foo_##name (int x) \
+{ \
+ _Complex type r; \
+ __real r = x + 1; \
+ __imag r = x - 1; \
+ return r; \
+} \
+ \
+void \
+bar_##name (type *x) \
+{ \
+ *x = __real foo_##name (5); \
+} \
+ \
+void \
+baz_##name (type *x) \
+{ \
+ *x = __imag foo_##name (5); \
+}
+
+typedef long double ldouble_t;
+typedef long long llong;
+
+T (float, float)
+T (double, double)
+T (long double, ldouble_t)
+T (char, char)
+T (short, short)
+T (int, int)
+T (long, long)
+T (long long, llong)
+#undef T
+
+int
+main (void)
+{
+#define T(type, name) \
+ { \
+ type var = 0; \
+ bar_##name (&var); \
+ if (var != 6) \
+ abort (); \
+ var = 0; \
+ baz_##name (&var); \
+ if (var != 4) \
+ abort (); \
+ }
+ T (float, float)
+ T (double, double)
+ T (long double, ldouble_t)
+ T (char, char)
+ T (short, short)
+ T (int, int)
+ T (long, long)
+ T (long long, llong)
+ return 0;
+}
--- /dev/null
+/* PR middle-end/19551 */
+/* { dg-options "-O2" } */
+/* { dg-do link } */
+
+extern void abort ();
+
+#define T(type, name) \
+extern __attribute__((pure)) _Complex type \
+foo_c##name (int x); \
+ \
+void \
+bar_c##name (type *x) \
+{ \
+ type f = __real foo_c##name (5); \
+ if (0) *x = f; \
+} \
+ \
+void \
+baz_c##name (type *x) \
+{ \
+ type f = __imag foo_c##name (5); \
+ if (0) *x = f; \
+} \
+ \
+extern __attribute__((pure)) type \
+foo_##name (int x); \
+ \
+void \
+bar_##name (type *x) \
+{ \
+ type f = foo_##name (5); \
+ if (0) *x = f; \
+}
+
+typedef long double ldouble_t;
+typedef long long llong;
+
+T (float, float)
+T (double, double)
+T (long double, ldouble_t)
+T (char, char)
+T (short, short)
+T (int, int)
+T (long, long)
+T (long long, llong)
+#undef T
+
+int
+main (void)
+{
+#define T(type, name) \
+ { \
+ type var = 0; \
+ bar_c##name (&var); \
+ baz_c##name (&var); \
+ bar_##name (&var); \
+ }
+ T (float, float)
+ T (double, double)
+ T (long double, ldouble_t)
+ T (char, char)
+ T (short, short)
+ T (int, int)
+ T (long, long)
+ T (long long, llong)
+ return 0;
+}