aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gimple-range-fold.cc6
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr104604.c34
2 files changed, 38 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)
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr104604.c b/gcc/testsuite/gcc.c-torture/execute/pr104604.c
new file mode 100644
index 0000000..c937e17
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr104604.c
@@ -0,0 +1,34 @@
+/* PR tree-optimization/104604 */
+
+unsigned char g;
+
+__attribute__((noipa))
+unsigned char
+foo (_Complex unsigned c)
+{
+ unsigned char v = g;
+ _Complex unsigned t = 3;
+ t /= c;
+ return v + t;
+}
+
+__attribute__((noipa))
+unsigned char
+bar (_Complex unsigned c)
+{
+ unsigned char v = g;
+ _Complex unsigned t = 42;
+ t /= c;
+ return v + t;
+}
+
+int
+main ()
+{
+ unsigned char x = foo (7);
+ if (x)
+ __builtin_abort ();
+ if (bar (7) != 6)
+ __builtin_abort ();
+ return 0;
+}