Commit 66c4f4d8 by Richard Biener Committed by Richard Biener

re PR tree-optimization/86945 (BUG with optimisation of select case statement in gfortran)

2018-08-22  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/86945
	* tree-cfg.c (generate_range_test): Use unsigned arithmetic.

	* gcc.dg/torture/pr86945.c: New testcase.

From-SVN: r263761
parent 30379cbf
2018-08-22 Richard Biener <rguenther@suse.de>
PR tree-optimization/86945
* tree-cfg.c (generate_range_test): Use unsigned arithmetic.
2018-08-22 Alexandre Oliva <oliva@adacore.com> 2018-08-22 Alexandre Oliva <oliva@adacore.com>
* config/rs6000/rs6000.c (SMALL_DATA_RELOC, SMALL_DATA_REG): Add * config/rs6000/rs6000.c (SMALL_DATA_RELOC, SMALL_DATA_REG): Add
......
2018-08-22 Richard Biener <rguenther@suse.de>
PR tree-optimization/86945
* tree-cfg.c (generate_range_test): Use unsigned arithmetic.
2018-08-21 Janne Blomqvist <jb@gcc.gnu.org> 2018-08-21 Janne Blomqvist <jb@gcc.gnu.org>
* gfortran.dg/nan_1.f90: Remove tests that test MAX/MIN with NaNs. * gfortran.dg/nan_1.f90: Remove tests that test MAX/MIN with NaNs.
......
/* { dg-do run } */
void __attribute__((noinline,noipa))
foo(int id)
{
switch (id)
{
case (-__INT_MAX__ - 1)...-1:
__builtin_abort ();
default:;
}
}
int main()
{
foo(1);
return 0;
}
...@@ -9131,20 +9131,16 @@ generate_range_test (basic_block bb, tree index, tree low, tree high, ...@@ -9131,20 +9131,16 @@ generate_range_test (basic_block bb, tree index, tree low, tree high,
tree type = TREE_TYPE (index); tree type = TREE_TYPE (index);
tree utype = unsigned_type_for (type); tree utype = unsigned_type_for (type);
low = fold_convert (type, low); low = fold_convert (utype, low);
high = fold_convert (type, high); high = fold_convert (utype, high);
tree tmp = make_ssa_name (type); gimple_seq seq = NULL;
gassign *sub1 index = gimple_convert (&seq, utype, index);
= gimple_build_assign (tmp, MINUS_EXPR, index, low); *lhs = gimple_build (&seq, MINUS_EXPR, utype, index, low);
*rhs = const_binop (MINUS_EXPR, utype, high, low);
*lhs = make_ssa_name (utype);
gassign *a = gimple_build_assign (*lhs, NOP_EXPR, tmp);
*rhs = fold_build2 (MINUS_EXPR, utype, high, low);
gimple_stmt_iterator gsi = gsi_last_bb (bb); gimple_stmt_iterator gsi = gsi_last_bb (bb);
gsi_insert_before (&gsi, sub1, GSI_SAME_STMT); gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT);
gsi_insert_before (&gsi, a, GSI_SAME_STMT);
} }
/* Emit return warnings. */ /* Emit return warnings. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment