On 3 August 2017 at 13:21, Jakub Jelinek <ja...@redhat.com> wrote: > On Thu, Aug 03, 2017 at 12:58:06PM +0530, Prathamesh Kulkarni wrote: >> --- a/gcc/tree-vrp.c >> +++ b/gcc/tree-vrp.c >> @@ -3778,6 +3778,19 @@ extract_range_basic (value_range *vr, gimple *stmt) >> return; >> } >> break; >> + case CFN_BUILT_IN_TOUPPER: >> + case CFN_BUILT_IN_TOLOWER: >> + if (tree lhs = gimple_call_lhs (stmt)) >> + { >> + tree type = TREE_TYPE (lhs); >> + unsigned char min = (cfn == CFN_BUILT_IN_TOUPPER) ? 'a' : 'A'; >> + unsigned char max = (cfn == CFN_BUILT_IN_TOUPPER) ? 'z' : 'Z'; >> + tree range_min = build_int_cstu (type, min); >> + tree range_max = build_int_cstu (type, max); >> + set_value_range (vr, VR_ANTI_RANGE, range_min, range_max, NULL); >> + return; > > You are hardcoding here host characters and using it for target. > I think you need to use > lang_hooks.to_target_charset > (really no idea how it works or doesn't in LTO, but gimple-fold.c is already > using it among others). > Also, you're assuming that the 'a'-'z' and 'A'-'Z' ranges are without gaps, > which isn't the case for e.g. EBCDIC. So I think you'd need to verify > (once?) that the target charset has this property. Hi Jakub, Thanks for the suggestions, I wasn't aware about lang_hooks.to_target_charset. Would following be a correct check that target has ascii charset and only then set range to ~[a, z] ?
target_a = lang_hooks.to_target_charset ('a'); target_z = lang_hooks.to_target_charset('z'); if (target_a == 'a' && target_z == 'z') { // set vr to ~['a', 'z'] } Thanks, Prathamesh > > Jakub