aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr68595.c13
-rw-r--r--gcc/tree-vect-stmts.c20
4 files changed, 43 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4dd84c7..48256e9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-12-01 Ilya Enkovich <enkovich.gnu@gmail.com>
+
+ PR middle-end/68595
+ * tree-vect-stmts.c (vect_init_vector): Cast boolean
+ scalars to a proper value before building a vector.
+
2015-12-01 Richard Sandiford <richard.sandiford@arm.com>
* genattrtab.c (check_attr_test): Take an attr_desc instead of
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e79db4e..07a9e52 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-12-01 Ilya Enkovich <enkovich.gnu@gmail.com>
+
+ PR middle-end/68595
+ * gcc.dg/pr68595.c: New test.
+
2015-12-01 Christian Bruel <christian.bruel@st.com>
* gcc.target/arm/ftest-armv6-thumb.c: Remove NEED_ARM_FEATURE_UNALIGNED.
diff --git a/gcc/testsuite/gcc.dg/pr68595.c b/gcc/testsuite/gcc.dg/pr68595.c
new file mode 100644
index 0000000..179c6c3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr68595.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+int a, b;
+char c;
+void fn1() {
+ b = 30;
+ for (; b <= 32; b++) {
+ c = -17;
+ for (; c <= 56; c++)
+ a -= 0 == (c || b);
+ }
+}
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 3b078da..5bb2289 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -1300,7 +1300,25 @@ vect_init_vector (gimple *stmt, tree val, tree type, gimple_stmt_iterator *gsi)
{
if (!types_compatible_p (TREE_TYPE (type), TREE_TYPE (val)))
{
- if (CONSTANT_CLASS_P (val))
+ /* Scalar boolean value should be transformed into
+ all zeros or all ones value before building a vector. */
+ if (VECTOR_BOOLEAN_TYPE_P (type))
+ {
+ tree true_val = build_zero_cst (TREE_TYPE (type));
+ tree false_val = build_all_ones_cst (TREE_TYPE (type));
+
+ if (CONSTANT_CLASS_P (val))
+ val = integer_zerop (val) ? false_val : true_val;
+ else
+ {
+ new_temp = make_ssa_name (TREE_TYPE (type));
+ init_stmt = gimple_build_assign (new_temp, COND_EXPR,
+ val, true_val, false_val);
+ vect_init_vector_1 (stmt, init_stmt, gsi);
+ val = new_temp;
+ }
+ }
+ else if (CONSTANT_CLASS_P (val))
val = fold_convert (TREE_TYPE (type), val);
else
{