diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr98727.c | 20 | ||||
-rw-r--r-- | gcc/tree-ssa-math-opts.c | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr98727.c b/gcc/testsuite/gcc.c-torture/execute/pr98727.c new file mode 100644 index 0000000..7ecdef8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr98727.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/98727 */ + +__attribute__((noipa)) long int +foo (long int x, long int y) +{ + long int z = (unsigned long) x * y; + if (x != z / y) + return -1; + return z; +} + +int +main () +{ + if (foo (4, 24) != 96 + || foo (124, 126) != 124L * 126 + || foo (__LONG_MAX__ / 16, 17) != -1) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index 5175ab5..d6201d3 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -4170,6 +4170,7 @@ match_arith_overflow (gimple_stmt_iterator *gsi, gimple *stmt, rhs2 = fold_convert (type, rhs2); else { + g = SSA_NAME_DEF_STMT (rhs2); if (gimple_assign_cast_p (g) && useless_type_conversion_p (type, TREE_TYPE (gimple_assign_rhs1 (g))) |