aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-range-fold.cc
AgeCommit message (Collapse)AuthorFilesLines
2021-07-26Confirm and Handle only ASCII in toupper and tolower ranges.Andrew MacLeod1-10/+39
PR tree-optimization/78888 * gimple-range-fold.cc (get_letter_range): New. (fold_using_range::range_of_builtin_call): Call get_letter_range.
2021-07-26Adjust ranges for to_upper and to_lower.Andrew MacLeod1-0/+32
Exclude lower case chars from to_upper and upper case chars from to_lower. gcc/ PR tree-optimization/78888 * gimple-range-fold.cc (fold_using_range::range_of_builtin_call): Add cases for CFN_BUILT_IN_TOUPPER and CFN_BUILT_IN_TOLOWER. gcc/testsuite/ * gcc.dg/pr78888.c: New.
2021-07-22Check for undefined on COND_EXPR before querying type.Andrew MacLeod1-1/+2
gcc/ PR tree-optimization/101497 * gimple-range-fold.cc (fold_using_range::range_of_cond_expr): Check for undefined. gcc/testsuite * gcc.dg/pr101497.c: New.
2021-07-15Add gimple_range_type for statements.Andrew MacLeod1-25/+19
The existing mechanisms for picking up the type of a statement are inconsistent with the needs of ranger. Encapsulate all the bits required to pick up the return type of a statement in one place, and check whether the type is supported. * gimple-range-fold.cc (adjust_pointer_diff_expr): Use gimple_range_type. (fold_using_range::fold_stmt): Ditto. (fold_using_range::range_of_range_op): Ditto. (fold_using_range::range_of_phi): Ditto. (fold_using_range::range_of_call): Ditto. (fold_using_range::range_of_builtin_ubsan_call): Ditto. (fold_using_range::range_of_builtin_call): Ditto. (fold_using_range::range_of_cond_expr): Ditto. * gimple-range-fold.h (gimple_range_type): New.
2021-07-12Add relation processing to ubsan builtins.Andrew MacLeod1-1/+3
Ubsan builtins call the plus/minus/multiple fold routines, but did not use any relation information between the 2 operands that is available. query and pass any relations. This resolves gcc.dg/pr97505.c when operating in ranger-only mode. * gimple-range-fold.cc (fold_using_range::range_of_builtin_ubsan_call): Query relation between the 2 operands and use it.
2021-06-24Only register relations on live edgesAndrew MacLeod1-6/+23
Register a relation on a conditional edge only if the LHS supports this edge being taken. gcc/ PR tree-optimization/101189 * gimple-range-fold.cc (fold_using_range::range_of_range_op): Pass LHS range of condition to postfold routine. (fold_using_range::postfold_gcond_edges): Only process the TRUE or FALSE edge if the LHS range supports it being taken. * gimple-range-fold.h (postfold_gcond_edges): Add range parameter. gcc/testsuite/ * gcc.dg/tree-ssa/pr101189.c: New.
2021-06-23Split gimple-range into gimple-range-fold and gimple-range.Andrew MacLeod1-0/+1331
Split the fold_using_range functions from gimple-range into gimple-range-fold. Also move the gimple_range_calc* routines into gimple-range-gori. * Makefile.in (OBJS): Add gimple-range-fold.o * gimple-range-fold.cc: New. * gimple-range-fold.h: New. * gimple-range-gori.cc (gimple_range_calc_op1): Move to here. (gimple_range_calc_op2): Ditto. * gimple-range-gori.h: Move prototypes to here. * gimple-range.cc: Adjust include files. (fur_source:fur_source): Relocate to gimple-range-fold.cc. (fur_source::get_operand): Ditto. (fur_source::get_phi_operand): Ditto. (fur_source::query_relation): Ditto. (fur_source::register_relation): Ditto. (class fur_edge): Ditto. (fur_edge::fur_edge): Ditto. (fur_edge::get_operand): Ditto. (fur_edge::get_phi_operand): Ditto. (fur_stmt::fur_stmt): Ditto. (fur_stmt::get_operand): Ditto. (fur_stmt::get_phi_operand): Ditto. (fur_stmt::query_relation): Ditto. (class fur_depend): Relocate to gimple-range-fold.h. (fur_depend::fur_depend): Relocate to gimple-range-fold.cc. (fur_depend::register_relation): Ditto. (fur_depend::register_relation): Ditto. (class fur_list): Ditto. (fur_list::fur_list): Ditto. (fur_list::get_operand): Ditto. (fur_list::get_phi_operand): Ditto. (fold_range): Ditto. (adjust_pointer_diff_expr): Ditto. (gimple_range_adjustment): Ditto. (gimple_range_base_of_assignment): Ditto. (gimple_range_operand1): Ditto. (gimple_range_operand2): Ditto. (gimple_range_calc_op1): Relocate to gimple-range-gori.cc. (gimple_range_calc_op2): Ditto. (fold_using_range::fold_stmt): Relocate to gimple-range-fold.cc. (fold_using_range::range_of_range_op): Ditto. (fold_using_range::range_of_address): Ditto. (fold_using_range::range_of_phi): Ditto. (fold_using_range::range_of_call): Ditto. (fold_using_range::range_of_builtin_ubsan_call): Ditto. (fold_using_range::range_of_builtin_call): Ditto. (fold_using_range::range_of_cond_expr): Ditto. (fold_using_range::range_of_ssa_name_with_loop_info): Ditto. (fold_using_range::relation_fold_and_or): Ditto. (fold_using_range::postfold_gcond_edges): Ditto. * gimple-range.h: Add gimple-range-fold.h to include files. Change GIMPLE_RANGE_STMT_H to GIMPLE_RANGE_H. (gimple_range_handler): Relocate to gimple-range-fold.h. (gimple_range_ssa_p): Ditto. (range_compatible_p): Ditto. (class fur_source): Ditto. (class fur_stmt): Ditto. (class fold_using_range): Ditto. (gimple_range_calc_op1): Relocate to gimple-range-gori.h (gimple_range_calc_op2): Ditto.