Re: [PATCH] gimple ssa: Don't use __builtin_popcount in switch exp transform [PR116616]

2024-09-06 Thread Richard Biener
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); > > t

Re: [PATCH] gimple ssa: Don't use __builtin_popcount in switch exp transform [PR116616]

2024-09-06 Thread Jakub Jelinek
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) > t

Re: [PATCH] gimple ssa: Don't use __builtin_popcount in switch exp transform [PR116616]

2024-09-06 Thread Andrew Pinski
On Fri, Sep 6, 2024 at 12:07 AM Filip Kastl wrote: > > Hi, > > bootstrapped and regtested on x86_64-linux. Ok to push? > > Thanks, > Filip Kastl > > > 8< > > > Switch exponential transformation in the switch conversion pass > currently generates > > tmp1 = __builtin_popcount (var); > tm

[PATCH] gimple ssa: Don't use __builtin_popcount in switch exp transform [PR116616]

2024-09-06 Thread Filip Kastl
Hi, bootstrapped and regtested on x86_64-linux. Ok to push? Thanks, Filip Kastl 8< Switch exponential transformation in the switch conversion pass currently generates tmp1 = __builtin_popcount (var); tmp2 = tmp1 == 1; when inserting code to determine if var is power of two. If t