]> gcc.gnu.org Git - gcc.git/commitdiff
middle-end/103485 - fix conversion kind for vectors
authorRichard Biener <rguenther@suse.de>
Tue, 30 Nov 2021 07:19:24 +0000 (08:19 +0100)
committerRichard Biener <rguenther@suse.de>
Tue, 30 Nov 2021 08:16:41 +0000 (09:16 +0100)
This makes sure to use a VIEW_CONVERT_EXPR for converting
vector signedness in the -((int)x >> (prec - 1)) to (unsigned)x >> (prec - 1)
simplification.

2021-11-30  Richard Biener  <rguenther@suse.de>

PR middle-end/103485
* match.pd (-((int)x >> (prec - 1)) to (unsigned)x >> (prec - 1)):
Use VIEW_CONVERT_EXPR for vectors.

* gcc.dg/pr103485.c: New testcase.

gcc/match.pd
gcc/testsuite/gcc.dg/pr103485.c [new file with mode: 0644]

index e14f97ee1cda805f4e416a236de0d1770e9c933d..d467a1c4e45314745eacf66d45e737aec4257985 100644 (file)
@@ -1611,7 +1611,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (with { tree stype = TREE_TYPE (@0);
          tree ntype = TYPE_UNSIGNED (stype) ? signed_type_for (stype)
                                             : unsigned_type_for (stype); }
-   (convert (rshift:ntype (convert:ntype @0) @1)))))
+   (if (VECTOR_TYPE_P (type))
+    (view_convert (rshift (view_convert:ntype @0) @1))
+    (convert (rshift (convert:ntype @0) @1))))))
 
 /* Try to fold (type) X op CST -> (type) (X op ((type-x) CST))
    when profitable.
diff --git a/gcc/testsuite/gcc.dg/pr103485.c b/gcc/testsuite/gcc.dg/pr103485.c
new file mode 100644 (file)
index 0000000..1afa928
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+
+int foo_v256u128_0;
+unsigned __attribute__((__vector_size__ (sizeof(unsigned) * 8))) foo_v256u8_0;
+
+void
+foo (void)
+{
+  foo_v256u8_0 -= (foo_v256u8_0 >> sizeof (foo_v256u8_0) - 1) + foo_v256u128_0;
+}
This page took 0.088914 seconds and 5 git commands to generate.