On Tue, 3 Nov 2026, Jakub Jelinek wrote: > On Tue, Nov 03, 2026 at 10:43:27AM +0100, [email protected] wrote: > > From: Kyrylo Tkachov <[email protected]> > > > > cfn_clz::fold_range computes the minimum of the result from the upper > > bound of the argument, and cfn_ctz::fold_range computes the maximum of > > the result from it. This is wrong for a signed argument with negative > > values, because a negative value has the sign bit set. For > > > > _1 = .CLZ (x_4(D)); > > _2 = _1 > 0; > > > > with int x_4(D), evrp computes > > > > Global Exported: _1 = [irange] int [1, 31] > > .CLZ/.CTZ is only defined for unsigned types, not for signed ones. > The fact that __GIMPLE parsing doesn't reject all kinds of invalid > stuff doesn't mean it is valid. > else if (!TYPE_UNSIGNED (TREE_TYPE (args[0]))) > { > if (complain) > error_at (ARG_LOCATION (0), > "argument 1 in call to function " > "%qE has signed type", > fndecl); > return false; > } > in c-common.cc rejects signed arguments to __builtin_clzg/__builtin_ctzg > etc. (they are allowed (and required) for __builtin_ffsg and > __builtin_clrsbg).
I'd appreciate amending doc/ifn.texi but also starting a ifn-specific section of verify_gimple_call. We might want to amend internal-fn.def with some basic information such as the min/max number of arguments and maybe a set of flags for example requiring uniformity of argument/result types. Or simply start with open-coding a switch/case for each IFN_* in verify_gimple_call. Richard. > Jakub > > -- Richard Biener <[email protected]> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg)
