https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120434
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amacleod at redhat dot com, | |jakub at gcc dot gnu.org --- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Like for divmod, expansion can use get_range_pos_neg (treeop) == 1 test to find out if the value range for some tree is known to be in the range [0, signed_max] and then could try to expand the extension twice and compare cost. Doing it solely in the backend expanders would be hard, because we wouldn't know the tree to call it on. But yet another option would be new optab which would stand for either sign or zero extension, whatever is cheaper. Anyway, it won't help for this particular testcase, because get_range_pos_neg uses the global range. And it wouldn't be very easy to change the expander to use statement specific ranger, because during expansion some basic blocks have still gimple IL but others already have RTL IL. So, in order to make it work we'd e.g. have to remember on the side for each SSA_NAME use in each stmt the corresponding ranges or something like that before starting changing the IL.