rs6000.c (rs6000_gimple_fold_builtin): Return early if there is no lhs.
authorWill Schmidt <willschm@gcc.gnu.org>
Thu, 13 Jul 2017 14:09:12 +0000 (14:09 +0000)
committerWill Schmidt <willschm@gcc.gnu.org>
Thu, 13 Jul 2017 14:09:12 +0000 (14:09 +0000)
[gcc]

2017-07-12  Will Schmidt  <will_schmidt@vnet.ibm.com>

* config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Return
early if there is no lhs.

[testsuite]

2017-07-12  Will Schmidt  <will_schmidt@vnet.ibm.com>

* gcc.target/powerpc/fold-vec-missing-lhs: New.

From-SVN: r250185

gcc/ChangeLog
gcc/config/rs6000/rs6000.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/fold-vec-missing-lhs.c [new file with mode: 0644]

index 3246378..2a4f082 100644 (file)
@@ -1,3 +1,8 @@
+       2017-07-13  Will Schmidt  <will_schmidt@vnet.ibm.com>
+
+       * config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Return
+       early if there is no lhs.
+
 2017-07-13  Martin Liska  <mliska@suse.cz>
 
        * dwarf2out.c (gen_pointer_type_die): Remove dead code.
index af5b5f1..a114d61 100644 (file)
@@ -16302,6 +16302,10 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi)
     = (enum rs6000_builtins) DECL_FUNCTION_CODE (fndecl);
   tree arg0, arg1, lhs;
 
+  /* Generic solution to prevent gimple folding of code without a LHS.  */
+  if (!gimple_call_lhs (stmt))
+    return false;
+
   switch (fn_code)
     {
     /* Flavors of vec_add.  We deliberately don't expand
index b5ca7fa..b24aab8 100644 (file)
@@ -1,3 +1,7 @@
+       2017-07-13  Will Schmidt  <will_schmidt@vnet.ibm.com>
+
+       * gcc.target/powerpc/fold-vec-missing-lhs.c: New.
+
 2017-07-13  Martin Liska  <mliska@suse.cz>
 
        * c-c++-common/ubsan/sanitize-all-1.c: Update scanned pattern.
diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-missing-lhs.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-missing-lhs.c
new file mode 100644 (file)
index 0000000..6add903
--- /dev/null
@@ -0,0 +1,24 @@
+/* This test is meant to verify that the gimple-folding does not
+   occur when the LHS portion of an expression is missing.
+   The intent of this test is to verify that we do not generate an ICE.
+   This was noticed during debug of PR81317.  */
+
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* { dg-options "-maltivec" } */
+
+#include <altivec.h>
+
+vector signed short
+test1_nolhs (vector bool short x, vector signed short y)
+{
+  vec_add (x, y);
+  return vec_add (x, y);
+}
+
+vector signed short
+test2_nolhs (vector signed short x, vector bool short y)
+{
+  vec_add (x, y);
+  return vec_add (x, y);
+}