diff mbox

Fix PR63605

Message ID alpine.LSU.2.11.1411071329560.27850@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Nov. 7, 2014, 12:30 p.m. UTC
The following fixes a bogus folding when applied to vectors.

Bootstrap and regtest pending on x86_64-unknown-linux-gnu.

Richard.

2014-11-07  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/63605
	* fold-const.c (fold_binary_loc): Properly use element_precision
	for types that may not be scalar.

	* gcc.dg/vect/pr63605.c: New testcase.
diff mbox

Patch

Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c	(revision 217214)
+++ gcc/fold-const.c	(working copy)
@@ -12817,7 +12729,7 @@  fold_binary_loc (location_t loc,
 	  tree arg00 = TREE_OPERAND (arg0, 0);
 	  tree arg01 = TREE_OPERAND (arg0, 1);
 	  tree itype = TREE_TYPE (arg00);
-	  if (wi::eq_p (arg01, TYPE_PRECISION (itype) - 1))
+	  if (wi::eq_p (arg01, element_precision (itype) - 1))
 	    {
 	      if (TYPE_UNSIGNED (itype))
 		{
Index: gcc/testsuite/gcc.dg/vect/pr63605.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/pr63605.c	(revision 0)
+++ gcc/testsuite/gcc.dg/vect/pr63605.c	(working copy)
@@ -0,0 +1,22 @@ 
+/* { dg-do run } */
+
+#include "tree-vect.h"
+
+extern void abort (void);
+
+int a, b[8] = { 2, 0, 0, 0, 0, 0, 0, 0 }, c[8];
+
+int
+main ()
+{
+  int d;
+  check_vect ();
+  for (; a < 8; a++)
+    {
+      d = b[a] >> 1;
+      c[a] = d != 0;
+    }
+  if (c[0] != 1)
+    abort ();
+  return 0;
+}