fold_convertible_p expects an operand and a type to convert to
but recurses with two vector component types. Fixed by allowing
types instead of an operand as well.
2022-04-04 Richard Biener <rguenther@suse.de>
PR middle-end/105140
* fold-const.cc (fold_convertible_p): Allow a TYPE_P arg.
* gcc.dg/pr105140.c: New testcase.
return build_vector_from_val (type, t);
}
-/* Returns true, if ARG is convertible to TYPE using a NOP_EXPR. */
+/* Returns true, if ARG, an operand or a type, is convertible to TYPE
+ using a NOP_EXPR. */
bool
fold_convertible_p (const_tree type, const_tree arg)
{
- tree orig = TREE_TYPE (arg);
+ const_tree orig = TYPE_P (arg) ? arg : TREE_TYPE (arg);
if (type == orig)
return true;
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-Os -w -Wno-psabi" } */
+
+typedef char __attribute__((__vector_size__ (16 * sizeof (char)))) U;
+typedef int __attribute__((__vector_size__ (16 * sizeof (int)))) V;
+
+void bar ();
+
+bar (int i, int j, int k, V v)
+{
+}
+
+void
+foo (void)
+{
+ bar ((V){}, (V){}, (V){}, (U){});
+}