aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-03-31 11:06:43 +0200
committerJakub Jelinek <jakub@redhat.com>2020-03-31 11:06:43 +0200
commit1dcffc8ddc48f0b45d3d0d2f763ef5870560eb9a (patch)
treeb000d2ce959c64e6d7afc16c63c7c9a73d918008 /gcc/fold-const.c
parent5ea39b2412269d208bb6ebd78303815957bd4f70 (diff)
downloadgcc-1dcffc8ddc48f0b45d3d0d2f763ef5870560eb9a.zip
gcc-1dcffc8ddc48f0b45d3d0d2f763ef5870560eb9a.tar.gz
gcc-1dcffc8ddc48f0b45d3d0d2f763ef5870560eb9a.tar.bz2
fold-const: Fix division folding with vector operands [PR94412]
The following testcase is miscompiled since 4.9, we treat unsigned vector types as if they were signed and "optimize" negations across it. 2020-03-31 Marc Glisse <marc.glisse@inria.fr> Jakub Jelinek <jakub@redhat.com> PR middle-end/94412 * fold-const.c (fold_binary_loc) <case TRUNC_DIV_EXPR>: Use ANY_INTEGRAL_TYPE_P instead of INTEGRAL_TYPE_P. * gcc.c-torture/execute/pr94412.c: New test. Co-authored-by: Marc Glisse <marc.glisse@inria.fr>
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 9267914..b79d059 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -11148,11 +11148,11 @@ fold_binary_loc (location_t loc, enum tree_code code, tree type,
/* Convert -A / -B to A / B when the type is signed and overflow is
undefined. */
- if ((!INTEGRAL_TYPE_P (type) || TYPE_OVERFLOW_UNDEFINED (type))
+ if ((!ANY_INTEGRAL_TYPE_P (type) || TYPE_OVERFLOW_UNDEFINED (type))
&& TREE_CODE (op0) == NEGATE_EXPR
&& negate_expr_p (op1))
{
- if (INTEGRAL_TYPE_P (type))
+ if (ANY_INTEGRAL_TYPE_P (type))
fold_overflow_warning (("assuming signed overflow does not occur "
"when distributing negation across "
"division"),
@@ -11162,11 +11162,11 @@ fold_binary_loc (location_t loc, enum tree_code code, tree type,
TREE_OPERAND (arg0, 0)),
negate_expr (op1));
}
- if ((!INTEGRAL_TYPE_P (type) || TYPE_OVERFLOW_UNDEFINED (type))
+ if ((!ANY_INTEGRAL_TYPE_P (type) || TYPE_OVERFLOW_UNDEFINED (type))
&& TREE_CODE (arg1) == NEGATE_EXPR
&& negate_expr_p (op0))
{
- if (INTEGRAL_TYPE_P (type))
+ if (ANY_INTEGRAL_TYPE_P (type))
fold_overflow_warning (("assuming signed overflow does not occur "
"when distributing negation across "
"division"),