aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-range-fold.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-02-22 10:43:13 +0100
committerJakub Jelinek <jakub@redhat.com>2022-02-22 10:43:13 +0100
commitd44dc131f48254fccc69ec4178fec030e0e2761d (patch)
tree741f4f158e9c6e4750a4852eadabbba6ff6b29ae /gcc/gimple-range-fold.cc
parent7e691189ca9c04fdba71ceada1faba62afbc1463 (diff)
downloadgcc-d44dc131f48254fccc69ec4178fec030e0e2761d.zip
gcc-d44dc131f48254fccc69ec4178fec030e0e2761d.tar.gz
gcc-d44dc131f48254fccc69ec4178fec030e0e2761d.tar.bz2
ranger: Fix up REALPART_EXPR/IMAGPART_EXPR handling [PR104604]
The following testcase is miscompiled since r12-3328. That change assumed that if rhs1 of a GIMPLE_ASSIGN is COMPLEX_CST, then that is the value of the lhs of the stmt, but that is not the case always, only if it is a GIMPLE_SINGLE_RHS stmt. If it is e.g. GIMPLE_UNARY_RHS or GIMPLE_BINARY_RHS (the latter happens in the testcase), then it can be e.g. __complex__ (3, 0) / var and the REALPART_EXPR of that isn't 3, but the realpart of the division. I assume once the ranger can do complex numbers adjust_*part_expr will just fetch one or the other range from a underlying complex range, but until then, we should limit this to what r12-3328 meant to do. 2022-02-22 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/104604 * gimple-range-fold.cc (adjust_imagpart_expr, adjust_realpart_expr): Only check if gimple_assign_rhs1 is COMPLEX_CST if gimple_assign_rhs_code is COMPLEX_CST. * gcc.c-torture/execute/pr104604.c: New test.
Diffstat (limited to 'gcc/gimple-range-fold.cc')
-rw-r--r--gcc/gimple-range-fold.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index 2fc8376..dfacf6f 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -397,7 +397,8 @@ adjust_imagpart_expr (irange &res, const gimple *stmt)
}
return;
}
- if (is_gimple_assign (def_stmt))
+ if (is_gimple_assign (def_stmt)
+ && gimple_assign_rhs_code (def_stmt) == COMPLEX_CST)
{
tree cst = gimple_assign_rhs1 (def_stmt);
if (TREE_CODE (cst) == COMPLEX_CST)
@@ -422,7 +423,8 @@ adjust_realpart_expr (irange &res, const gimple *stmt)
if (!SSA_NAME_DEF_STMT (name))
return;
- if (is_gimple_assign (def_stmt))
+ if (is_gimple_assign (def_stmt)
+ && gimple_assign_rhs_code (def_stmt) == COMPLEX_CST)
{
tree cst = gimple_assign_rhs1 (def_stmt);
if (TREE_CODE (cst) == COMPLEX_CST)