> On May 25, 2022, at 7:34 AM, Richard Biener via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > On Tue, May 24, 2022 at 3:55 PM Roger Sayle <ro...@nextmovesoftware.com> > wrote: >> >> >> "For every pessimization, there's an equal and opposite optimization". >> >> In the review of my original patch for PR middle-end/98865, Richard >> Biener pointed out that match.pd shouldn't be transforming X*Y into >> X&-Y as the former is considered cheaper by tree-ssa's cost model >> (operator count). A corollary of this is that we should instead be >> transforming X&-Y into the cheaper X*Y as a preferred canonical form >> (especially as RTL expansion now intelligently selects the appropriate >> implementation based on the target's costs). >> >> With this patch we now generate identical code for: >> int foo(int x, int y) { return -(x&1) & y; } >> int bar(int x, int y) { return (x&1) * y; } What, if anything, does the target description have to do for "the appropriate implementation" to be selected? For example, if the target has an "AND with complement" operation, it's probably cheaper than multiply and would be the preferred generated code. paul
Re: [PATCH] Canonicalize X&-Y as X*Y in match.pd when Y is [0,1].
Koning, Paul via Gcc-patches Wed, 25 May 2022 06:41:09 -0700
- [PATCH] Canonicalize X&-Y as X*Y in mat... Roger Sayle
- Re: [PATCH] Canonicalize X&-Y as X... Richard Biener via Gcc-patches
- Re: [PATCH] Canonicalize X&-Y ... Koning, Paul via Gcc-patches
- RE: [PATCH] Canonicalize X&... Roger Sayle
- Re: [PATCH] Canonicalize X... Koning, Paul via Gcc-patches