On Mon, Jul 26, 2021 at 03:44:28PM -0400, Andrew MacLeod via Gcc-patches wrote: > I'm testing this... Think this'll work better? we don't support any > character sets where a space is 32 but it isnt ASCI.. and 64 isnt EBCDIC? > > This should handle those 2 sets.. and if is something else, it bails. > > This seems OK? Im testing it now on x86-64... but dont have an ebcdic > target...
> --- a/gcc/gimple-range-fold.cc > +++ b/gcc/gimple-range-fold.cc > @@ -37,6 +37,7 @@ along with GCC; see the file COPYING3. If not see > #include "cfgloop.h" > #include "tree-ssa-loop.h" > #include "tree-scalar-evolution.h" > +#include "langhooks.h" > #include "vr-values.h" > #include "range.h" > #include "value-query.h" > @@ -835,6 +836,43 @@ fold_using_range::range_of_builtin_ubsan_call (irange > &r, gcall *call, > r.set_varying (type); > } > > +// Return TRUE if we recognize the target character set and return the > +// range for lower case and upper case letters. > + > +static bool > +get_letter_range (tree type, irange &lowers, irange &uppers) > +{ > + // ASCII > + if (lang_hooks.to_target_charset (' ') == 0x20) > + { > + lowers = int_range<2> (build_int_cst (type, 'a'), > + build_int_cst (type, 'z')); > + uppers = int_range<2> (build_int_cst (type, 'A'), > + build_int_cst (type, 'Z')); Wouldn't it be safer to lang_hooks.to_target_charset ('a') (and 'z') and just verify that their difference is that of 'z' - 'a' and use that range and IMHO just don't bother with EBCDIC or other charsets? Jakub