[EXT] Re: [PATCH] Optimize and+or+sub into xor+not (PR94882)
Richard Biener
richard.guenther@gmail.com
Thu Jun 4 08:14:33 GMT 2020
On Wed, Jun 3, 2020 at 12:36 PM Naveen Hurugalawadi <naveenh@marvell.com> wrote:
>
> Hi Richard,
>
> Thanks for reviewing the patch and sharing your comments.
>
> >> pattern should be guarded with !TYPE_OVERFLOW_SANITIZED
> >> and/or !TYPE_OVERFLOW_TRAPS
> Done.
>
> >> can you add some cases with unsigned types and types
> >> smaller than int (thus with integral promotion applied)?
> Done.
>
> Please find attached the modified patch as per your suggestions.
> Bootstrapped and regression tested on x86_64-pc-linux-gnu.
+(simplify
+ (plus (nop_convert1? (minus (nop_convert2? (bit_and @0 @1))
+ (nop_convert3? (bit_ior @0 @1))))
+ (nop_convert4? integer_all_onesp))
nop_convert4 cannot happen, constants will have been constant folded here.
nop_convert2 and nop_convert3 can only happen together since
the bit_and and the bit_ior will have the same type since they share operands.
Btw, one of bit_and or bit_ior needs :c.
+ (if (!TYPE_OVERFLOW_SANITIZED (type) && !TYPE_OVERFLOW_TRAPS (type)
+ && !TYPE_SATURATING (type))
since we now have two types, the type of the plus and the type of the minus
you have to check both of them
So I think it should be
(simplify
(plus (nop_convert1? (minus@2 (nop_convert2? (bit_and:c @0 @1))
(nop_convert2?
(bit_ior @0 @1))))
integer_all_onesp)
(if (!TYPE_OVERFLOW_SANITIZED (type) && !TYPE_OVERFLOW_TRAPS (type)
&& !TYPE_SATURATING (type)
&& !TYPE_OVERFLOW_SANITIZED (TREE_TYPE (@2))
&& !TYPE_OVERFLOW_TRAPS (TREE_TYPE (@2))
&& !TYPE_SATURATING (TREE_TYPE (@2)))
(bit_not (convert (bit_xor @0 @1))))))
and the other patterns adjusted accordingly.
Thanks,
Richard.
> Thanks,
> Naveen
More information about the Gcc-patches
mailing list