https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81165

--- Comment #6 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #5)
> we miss to optimize (int)((short int)((unsigned short) x1.1_4 ^ 8) & 1) to
> (int)(x1.1_4 & 1) as well.

(untested)

+/* (X |^ 8) & 1  -->  X & 1  */
+(for op (bit_ior bit_xor)
+ (simplify
+  (bit_and:c (convert?@4 (op:c@3 @0 (with_possible_nonzero_bits2@1 @1z)))
+            (with_possible_nonzero_bits2@2 @2z))
+  (if (wi::bit_and
+       (wide_int::from (get_nonzero_bits (@1z), TYPE_PRECISION (type),
+                       TYPE_SIGN (TREE_TYPE (@1))),
+       get_nonzero_bits (@2z)) == 0
+       && single_use (@3) && single_use (@4))
+   (bit_and (convert @0) @2))))

Reply via email to