Re: [PATCH] match.pd: rewrite select to branchless expression

2022-11-17 Thread Jeff Law via Gcc-patches
On 11/8/22 13:15, Andrew Pinski via Gcc-patches wrote: On Tue, Nov 8, 2022 at 12:02 PM Michael Collison wrote: This patches transforms (cond (and (x , 0x1) == 0), y, (z op y)) into (-(and (x , 0x1)) & z ) op y, where op is a '^' or a '|'. It also transforms (cond (and (x , 0x1) != 0), (z op y

Re: [PATCH] match.pd: rewrite select to branchless expression

2022-11-10 Thread Richard Biener via Gcc-patches
On Wed, Nov 9, 2022 at 10:06 PM Michael Collison wrote: > > Richard, > > Thanks for your feedback. I want to make sure I am following what you > are recommending. Are you suggesting changing: > > (for op (bit_xor bit_ior) > (simplify > (cond (eq (bit_and @0 integer_onep@1) > integer_zerop) > @2 >

Re: [PATCH] match.pd: rewrite select to branchless expression

2022-11-09 Thread Michael Collison
Richard, Thanks for your feedback. I want to make sure I am following what you are recommending. Are you suggesting changing: (for op (bit_xor bit_ior) (simplify (cond (eq (bit_and @0 integer_onep@1) integer_zerop) @2 (op:c @3 @2)) (if (INTEGRAL_TYPE_P (type) && (INTEGRAL_TYPE_P (TREE_TYPE (@0

Re: [PATCH] match.pd: rewrite select to branchless expression

2022-11-08 Thread Richard Biener via Gcc-patches
On Tue, Nov 8, 2022 at 9:02 PM Michael Collison wrote: > > This patches transforms (cond (and (x , 0x1) == 0), y, (z op y)) into > (-(and (x , 0x1)) & z ) op y, where op is a '^' or a '|'. It also > transforms (cond (and (x , 0x1) != 0), (z op y), y ) into (-(and (x , > 0x1)) & z ) op y. > > Match

Re: [PATCH] match.pd: rewrite select to branchless expression

2022-11-08 Thread Andrew Pinski via Gcc-patches
On Tue, Nov 8, 2022 at 12:02 PM Michael Collison wrote: > > This patches transforms (cond (and (x , 0x1) == 0), y, (z op y)) into > (-(and (x , 0x1)) & z ) op y, where op is a '^' or a '|'. It also > transforms (cond (and (x , 0x1) != 0), (z op y), y ) into (-(and (x , > 0x1)) & z ) op y. > > Matc

[PATCH] match.pd: rewrite select to branchless expression

2022-11-08 Thread Michael Collison
This patches transforms (cond (and (x , 0x1) == 0), y, (z op y)) into (-(and (x , 0x1)) & z ) op y, where op is a '^' or a '|'. It also transforms (cond (and (x , 0x1) != 0), (z op y), y ) into (-(and (x , 0x1)) & z ) op y. Matching this patterns allows GCC to generate branchless code for one