Commit 0ccb5dbf by Jakub Jelinek Committed by Jakub Jelinek

re PR tree-optimization/46309 (optimization a==3||a==1)

	PR tree-optimization/46309
	* fold-const.c (make_range, merge_ranges): Remove prototypes.
	(make_range_step): New function.
	(make_range): Use it.
	* tree.h (make_range_step): New prototypes.
	* Makefile.in (tree-ssa-reassoc.o): Depend on $(DIAGNOSTIC_CORE_H).
	* tree-ssa-reassoc.c: Include diagnostic-core.h.
	(struct range_entry): New type.
	(init_range_entry, range_entry_cmp, update_range_test,
	optimize_range_tests): New functions.
	(reassociate_bb): Call optimize_range_tests.

	* gcc.dg/pr46309.c: New test.

From-SVN: r179388
parent 915afed6
2011-09-30 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/46309
* fold-const.c (make_range, merge_ranges): Remove prototypes.
(make_range_step): New function.
(make_range): Use it.
* tree.h (make_range_step): New prototypes.
* Makefile.in (tree-ssa-reassoc.o): Depend on $(DIAGNOSTIC_CORE_H).
* tree-ssa-reassoc.c: Include diagnostic-core.h.
(struct range_entry): New type.
(init_range_entry, range_entry_cmp, update_range_test,
optimize_range_tests): New functions.
(reassociate_bb): Call optimize_range_tests.
2011-09-30 Jakub Jelinek <jakub@redhat.com>
Richard Guenther <rguenther@suse.de>
* tree-ssa-structalias.c (find_func_aliases_for_builtin_call): Handle
......@@ -2650,7 +2650,7 @@ tree-ssa-reassoc.o : tree-ssa-reassoc.c $(TREE_FLOW_H) $(CONFIG_H) \
$(TM_H) coretypes.h $(TREE_DUMP_H) $(TREE_PASS_H) $(FLAGS_H) \
tree-iterator.h $(BASIC_BLOCK_H) $(GIMPLE_H) $(TREE_INLINE_H) \
$(VEC_H) langhooks.h alloc-pool.h pointer-set.h $(CFGLOOP_H) \
tree-pretty-print.h gimple-pretty-print.h
tree-pretty-print.h gimple-pretty-print.h $(DIAGNOSTIC_CORE_H)
tree-optimize.o : tree-optimize.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
$(TREE_H) $(TM_P_H) $(GGC_H) output.h \
$(DIAGNOSTIC_H) $(BASIC_BLOCK_H) $(FLAGS_H) $(TIMEVAR_H) $(TM_H) \
......
2011-09-30 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/46309
* gcc.dg/pr46309.c: New test.
2011-09-30 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/strlenopt-21.c: New test.
2011-09-30 Revital Eres <revital.eres@linaro.org>
......
/* PR tree-optimization/46309 */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-reassoc-details" } */
int
f1 (int a)
{
int v1 = (a == 3);
int v2 = (a == 1);
int v3 = (a == 4);
int v4 = (a == 2);
return v1 || v2 || v3 || v4;
}
int
f2 (int a)
{
int v1 = (a == 1);
int v2 = (a == 2);
int v3 = (a == 3);
int v4 = (a == 4);
return v1 || v2 || v3 || v4;
}
int
f3 (int a)
{
int v1 = (a == 3);
int v2 = (a == 1);
return v1 || v2;
}
int
f4 (int a)
{
int v1 = (a == 1);
int v2 = (a == 2);
return v1 || v2;
}
int
f5 (unsigned int a)
{
int v1 = (a <= 31);
int v2 = (a >= 64 && a <= 95);
return v1 || v2;
}
int
f6 (unsigned int a)
{
int v1 = (a <= 31);
int v2 = (a >= 64 && a <= 95);
int v3 = (a >= 128 && a <= 159);
int v4 = (a >= 192 && a <= 223);
return v1 || v2 || v3 || v4;
}
/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.1, 1. and -.2, 2. and -.3, 3. and -.4, 4.\[\n\r\]* into" 2 "reassoc1" } } */
/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.1, 1. and -.3, 3.\[\n\r\]* into" 1 "reassoc1" } } */
/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.1, 1. and -.2, 2.\[\n\r\]* into" 1 "reassoc1" } } */
/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.0, 31. and -.64, 95.\[\n\r\]* into" 2 "reassoc1" } } */
/* { dg-final { scan-tree-dump-times "Optimizing range tests a_\[0-9\]*.D. -.128, 159. and -.192, 223.\[\n\r\]* into" 1 "reassoc1" } } */
/* { dg-final { scan-tree-dump-times "Optimizing range tests D.\[0-9\]*_\[0-9\]* -.0, 31. and -.128, 159.\[\n\r\]* into" 1 "reassoc2" } } */
/* { dg-final { cleanup-tree-dump "reassoc1" } } */
/* { dg-final { cleanup-tree-dump "reassoc2" } } */
......@@ -5384,6 +5384,8 @@ extern unsigned int get_pointer_alignment (tree);
extern tree fold_call_stmt (gimple, bool);
extern tree gimple_fold_builtin_snprintf_chk (gimple, tree, enum built_in_function);
extern tree make_range (tree, int *, tree *, tree *, bool *);
extern tree make_range_step (location_t, enum tree_code, tree, tree, tree,
tree *, tree *, int *, bool *);
extern tree build_range_check (location_t, tree, tree, int, tree, tree);
extern bool merge_ranges (int *, tree *, tree *, int, tree, tree, int,
tree, tree);
......
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