From 1014b6f54b75b690b81dfac4b284961c2fb51646 Mon Sep 17 00:00:00 2001 From: Senthil Kumar Selvaraj Date: Thu, 19 Nov 2015 17:30:24 +0000 Subject: [Patch, vrp] Allow VRP type conversion folding only for widenings upto word mode * tree.h (desired_pro_or_demotion_p): New function. * tree-vrp.c (simplify_cond_using_ranges): Call it. * gcc.dg/tree-ssa/vrp98.c: New testcase. * gcc.target/avr/uint8-single-reg.c: New testcase. From-SVN: r230618 --- gcc/tree.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gcc/tree.h') diff --git a/gcc/tree.h b/gcc/tree.h index 41c0f7c..cb52deb 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -5358,4 +5358,18 @@ get_decl_source_range (tree decl) return get_range_from_loc (line_table, loc); } +/* Return true if it makes sense to promote/demote from_type to to_type. */ +inline bool +desired_pro_or_demotion_p (const_tree to_type, const_tree from_type) +{ + unsigned int to_type_precision = TYPE_PRECISION (to_type); + + /* OK to promote if to_type is no bigger than word_mode. */ + if (to_type_precision <= GET_MODE_PRECISION (word_mode)) + return true; + + /* Otherwise, allow only if narrowing or same precision conversions. */ + return to_type_precision <= TYPE_PRECISION (from_type); +} + #endif /* GCC_TREE_H */ -- cgit v1.1