https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108757
--- Comment #22 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #21) > (In reply to Jiu Fu Guo from comment #20) > > Interesting thing: > > the VR is always VR_VARYING, even for the below simple case: > > > > typedef unsigned long INT; > > INT __attribute__ ((noinline)) foo (INT x) > > { > > if (x < 4) > > return 0; > > INT a = x + 18446744073709551612ULL; > > INT b = a >> 2; > > return b + 1; > > } > > Yes that is because x does not have a "global" range. I also tried "get_range_query (cfun)->range_of_expr (vr0, @0)", > > You could try the following testcase: > ``` > typedef unsigned long INT; > INT __attribute__ ((noinline)) foo (INT x) > { > if (x < 4) > __builtin_unreachable(); > INT a = x + 18446744073709551612ULL; > INT b = a >> 2; > return b + 1; > } > ``` > > Which gets a (global) range for x_1(D) during forwprop3: > # RANGE [irange] INT [4, +INF] > INTD.2750 x_1(D) = xD.2751; (In reply to Andrew Pinski from comment #21) > (In reply to Jiu Fu Guo from comment #20) > > Interesting thing: > > the VR is always VR_VARYING, even for the below simple case: > > > > typedef unsigned long INT; > > INT __attribute__ ((noinline)) foo (INT x) > > { > > if (x < 4) > > return 0; > > INT a = x + 18446744073709551612ULL; > > INT b = a >> 2; > > return b + 1; > > } > > Yes that is because x does not have a "global" range. > > You could try the following testcase: > ``` > typedef unsigned long INT; > INT __attribute__ ((noinline)) foo (INT x) > { > if (x < 4) > __builtin_unreachable(); > INT a = x + 18446744073709551612ULL; > INT b = a >> 2; > return b + 1; > } > ``` > > Which gets a (global) range for x_1(D) during forwprop3: > # RANGE [irange] INT [4, +INF] > INTD.2750 x_1(D) = xD.2751; Thanks so much! "get_range_query (cfun)->range_of_expr (vr0, @0)" works for both the case!