]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
match.pd: Fix up (X & Y) CMP 0 -> X CMP2 ~Y simplifications [PR104499]
authorJakub Jelinek <jakub@redhat.com>
Fri, 11 Feb 2022 19:27:23 +0000 (20:27 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 11 Feb 2022 19:27:23 +0000 (20:27 +0100)
The following testcase ICEs on x86_64-linux, because match.pd emits
there a NOP_EXPR cast from int*8 vector type with BLKmode to
unsigned*8 vector type with BLKmode and vec-lowering isn't prepared
to handle such casts.

Fixed by using VIEW_CONVERT_EXPR instead.

2022-02-11  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/104499
* match.pd ((X & Y) CMP 0 -> X CMP2 ~Y): Use view_convert instead
of convert.

* gcc.c-torture/compile/pr104499.c: New test.

gcc/match.pd
gcc/testsuite/gcc.c-torture/compile/pr104499.c [new file with mode: 0644]

index 0f326233cbb963a1c681a3aab2ad9e200c4b9a0a..10f622848625986300cdef1edf3ab29de6300c0b 100644 (file)
@@ -5778,7 +5778,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
       (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
        (icmp @0 { csts; })
        (with { tree utype = unsigned_type_for (TREE_TYPE (@1)); }
-        (icmp (convert:utype @0) { csts; }))))))))
+        (icmp (view_convert:utype @0) { csts; }))))))))
 
 /* When one argument is a constant, overflow detection can be simplified.
    Currently restricted to single use so as not to interfere too much with
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr104499.c b/gcc/testsuite/gcc.c-torture/compile/pr104499.c
new file mode 100644 (file)
index 0000000..e5d5cdd
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR tree-optimization/104499 */
+
+typedef int __attribute__((__vector_size__ (8 * sizeof (int)))) V;
+
+V v;
+
+void
+foo (void)
+{
+  v = ((1 | v) != 1);
+}