>> (x & -1) == x >>(x | -1) == -1 >>(x ^ -1) == ~x Looks reasonable to me.
Do you mean modify the code as follows ? if (integer_zerop (arg1) || integer_zerop (arg2)) || integer_onep (arg1) || integer_onep(arg2)) step_ok_p = (code == BIT_AND_EXPR || code == BIT_IOR_EXPR || code == BIT_XOR_EXPR); juzhe.zh...@rivai.ai From: Jakub Jelinek Date: 2023-12-19 17:45 To: juzhe.zh...@rivai.ai CC: rguenther; Robin Dapp; gcc-patches; pan2.li; richard.sandiford; Richard Biener; pinskia Subject: Re: Re: [PATCH] fold-const: Handle AND, IOR, XOR with stepped vectors [PR112971]. On Tue, Dec 19, 2023 at 05:35:14PM +0800, juzhe.zh...@rivai.ai wrote: > I wonder whether we can simplify the codes as follows :? > if (integer_zerop (arg1) || integer_zerop (arg2)) > step_ok_p = (code == BIT_AND_EXPR || code == BIT_IOR_EXPR > || code == BIT_XOR_EXPR); What about integer_all_onesp (arg1) || integer_all_onesp (arg2) ? (x & -1) == x (x | -1) == -1 (x ^ -1) == ~x even for the VL vectors, no? Jakub