There was an embarrassing typo in the folding of BIT_NOT_EXPR for
POLY_INT_CSTs: it used - rather than ~ on the poly_int. Not sure
how that happened, but it might have been due to the way that
~x is implemented as -1 - x internally.
gcc/
PR tree-optimization/118976
* fold-const.cc (const_unop): Use ~ rather than - for BIT_NOT_EXPR.
* config/aarch64/aarch64.cc (aarch64_test_sve_folding): New function.
(aarch64_run_selftests): Run it.
}
}
+/* Test SVE arithmetic folding. */
+
+static void
+aarch64_test_sve_folding ()
+{
+ tree res = fold_unary (BIT_NOT_EXPR, ssizetype,
+ ssize_int (poly_int64 (1, 1)));
+ ASSERT_TRUE (operand_equal_p (res, ssize_int (poly_int64 (-2, -1))));
+}
+
/* Run all target-specific selftests. */
static void
aarch64_test_loading_full_dump ();
aarch64_test_fractional_cost ();
aarch64_test_sysreg_encoding_clashes ();
+ aarch64_test_sve_folding ();
}
} // namespace selftest
if (TREE_CODE (arg0) == INTEGER_CST)
return fold_not_const (arg0, type);
else if (POLY_INT_CST_P (arg0))
- return wide_int_to_tree (type, -poly_int_cst_value (arg0));
+ return wide_int_to_tree (type, ~poly_int_cst_value (arg0));
/* Perform BIT_NOT_EXPR on each element individually. */
else if (TREE_CODE (arg0) == VECTOR_CST)
{