--- /dev/null
+/* PR tree-optimization/119614 */
+/* { dg-do compile { target musttail } } */
+/* { dg-options "-O2" } */
+
+volatile int v;
+
+[[gnu::noinline]] const char *
+foo (int x)
+{
+ v += x;
+ return 0;
+}
+
+const char *
+bar (int x)
+{
+ if (x == 42)
+ [[gnu::musttail]] return foo (42);
+ [[gnu::musttail]] return foo (32);
+}
+
+const char *
+baz (int x)
+{
+ if (x == 5)
+ return foo (42);
+ return foo (32);
+}
--- /dev/null
+/* PR tree-optimization/119614 */
+/* { dg-do compile { target musttail } } */
+/* { dg-options "-O2" } */
+
+volatile int v;
+
+[[gnu::noinline]] const char *
+foo (int x)
+{
+ v += x;
+ return (const char *) -42;
+}
+
+const char *
+bar (int x)
+{
+ if (x == 42)
+ [[gnu::musttail]] return foo (42);
+ [[gnu::musttail]] return foo (32);
+}
+
+const char *
+baz (int x)
+{
+ if (x == 5)
+ return foo (42);
+ return foo (32);
+}
--- /dev/null
+/* PR tree-optimization/119614 */
+/* { dg-do compile { target musttail } } */
+/* { dg-options "-O2" } */
+
+volatile int v;
+
+[[gnu::noinline]] double
+foo (int x)
+{
+ v += x;
+ return 0.5;
+}
+
+double
+bar (int x)
+{
+ if (x == 42)
+ [[gnu::musttail]] return foo (42);
+ [[gnu::musttail]] return foo (32);
+}
+
+double
+baz (int x)
+{
+ if (x == 5)
+ return foo (42);
+ return foo (32);
+}
&& TREE_CONSTANT (ret_var))
if (tree type = gimple_range_type (call))
if (tree callee = gimple_call_fndecl (call))
- if ((INTEGRAL_TYPE_P (type) || SCALAR_FLOAT_TYPE_P (type))
+ if ((INTEGRAL_TYPE_P (type)
+ || SCALAR_FLOAT_TYPE_P (type)
+ || POINTER_TYPE_P (type))
&& useless_type_conversion_p (TREE_TYPE (TREE_TYPE (callee)),
type)
&& useless_type_conversion_p (TREE_TYPE (ret_var), type)