On Fri, 6 Sep 2024, Jakub Jelinek wrote: > On Fri, Sep 06, 2024 at 12:18:30AM -0700, Andrew Pinski wrote: > > You need to do this in an unsigned types. Otherwise you get the wrong > > answer and also introduce undefined code. > > So you need to use: > > tree utype = unsigned_type_for (type); > > tree tmp3; > > if (types_compatible_p (type, utype) > > tmp3 = op; > > else > > tmp3 = gimple_build (&gsi, false, GSI_NEW_STMT, loc, CONVERT_EXPR, utype, > > op); > > I think NOP_EXPR is used for these conversions instead.
There is gimple_convert to abstract this. Richard.