aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2018-01-13 17:57:17 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2018-01-13 17:57:17 +0000
commit779fed5fdb6098e67213a82dfd27f5b326a75e88 (patch)
treec7d81773fba7399e72265ef818081c1fb946baa9 /gcc/fold-const.c
parentdbc3af4fc620aeb6fbf088e961fe8658bbd959c7 (diff)
downloadgcc-779fed5fdb6098e67213a82dfd27f5b326a75e88.zip
gcc-779fed5fdb6098e67213a82dfd27f5b326a75e88.tar.gz
gcc-779fed5fdb6098e67213a82dfd27f5b326a75e88.tar.bz2
Fix folding of vector mask EQ/NE expressions
fold_binary_loc assumed that if the type of the result wasn't a vector, the operands wouldn't be either. This isn't necessarily true for EQ_EXPR and NE_EXPR of vector masks, which can return a single scalar for the mask as a whole. 2018-01-13 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * fold-const.c (fold_binary_loc): Check the argument types rather than the result type when testing for a vector operation. gcc/testsuite/ * gcc.target/aarch64/sve/vec_bool_cmp_1.c: New test. * gcc.target/aarch64/sve/vec_bool_cmp_1_run.c: Likweise. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r256616
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 521c2dc..cfb1b3d 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -9323,7 +9323,7 @@ fold_binary_loc (location_t loc, enum tree_code code, tree type,
if ((code == BIT_AND_EXPR || code == BIT_IOR_EXPR
|| code == EQ_EXPR || code == NE_EXPR)
- && TREE_CODE (type) != VECTOR_TYPE
+ && !VECTOR_TYPE_P (TREE_TYPE (arg0))
&& ((truth_value_p (TREE_CODE (arg0))
&& (truth_value_p (TREE_CODE (arg1))
|| (TREE_CODE (arg1) == BIT_AND_EXPR