--- /dev/null
+// { dg-do run }
+// PR middle-end/111285
+
+// The lowering of vect absu was done incorrectly
+
+#define vect1 __attribute__((vector_size(sizeof(int))))
+
+#define negabs(a) a < 0 ? a : -a
+
+__attribute__((noinline))
+int s(int a)
+{
+ return negabs(a);
+}
+__attribute__((noinline))
+vect1 int v(vect1 int a)
+{
+ return negabs(a);
+}
+
+int main(void)
+{
+ for(int i = -10; i < 10; i++)
+ {
+ vect1 int t = {i};
+ if (v(t)[0] != s(i))
+ __builtin_abort();
+ }
+}
tree b ATTRIBUTE_UNUSED, tree bitpos, tree bitsize,
enum tree_code code, tree type ATTRIBUTE_UNUSED)
{
- a = tree_vec_extract (gsi, inner_type, a, bitsize, bitpos);
+ tree rhs_type = inner_type;
+
+ /* For ABSU_EXPR, use the signed type for the rhs if the rhs was signed. */
+ if (code == ABSU_EXPR
+ && ANY_INTEGRAL_TYPE_P (TREE_TYPE (a))
+ && !TYPE_UNSIGNED (TREE_TYPE (a)))
+ rhs_type = signed_type_for (rhs_type);
+
+ a = tree_vec_extract (gsi, rhs_type, a, bitsize, bitpos);
return gimplify_build1 (gsi, code, inner_type, a);
}