aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.h
diff options
context:
space:
mode:
authorSenthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>2015-11-19 17:30:24 +0000
committerJeff Law <law@gcc.gnu.org>2015-11-19 10:30:24 -0700
commit1014b6f54b75b690b81dfac4b284961c2fb51646 (patch)
treec46d7a664854f1eb101011a8c8f91af5e052887e /gcc/tree.h
parent04a9bb6ec35a925ec15fcaafe16124748c3bfcc9 (diff)
downloadgcc-1014b6f54b75b690b81dfac4b284961c2fb51646.zip
gcc-1014b6f54b75b690b81dfac4b284961c2fb51646.tar.gz
gcc-1014b6f54b75b690b81dfac4b284961c2fb51646.tar.bz2
[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
Diffstat (limited to 'gcc/tree.h')
-rw-r--r--gcc/tree.h14
1 files changed, 14 insertions, 0 deletions
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 */