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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andi Kleen from comment #2)
> Is that the right pattern for the example? It looks different

Yes I am positive it is the right one. I double checked even GCC 14.1.0 and
13.3.0.
> 
> Enabling match.pd debugging for the scalar version shows:
> 
> taddbit.c.034t.ccp1:Applying pattern match.pd:3960, gimple-match.cc:18437
> taddbit.c.034t.ccp1:Applying pattern match.pd:3760, gimple-match.cc:14134
> taddbit.c.035t.forwprop1:Applying pattern match.pd:3960,
> gimple-match.cc:18437
> taddbit.c.035t.forwprop1:Applying pattern match.pd:3760,
> gimple-match.cc:14134
> taddbit.c.035t.forwprop1:Applying pattern match.pd:1880,
> gimple-match.cc:34062

Those line # seems like they are from GCC 13.3.0. line 3960 is exactly that
pattern in GCC 13.3.0 even.

84ff66b884e9 (Andre Vieira             2015-10-09 16:08:35 +0000 3951) /* Fold
(X {&,^,|} C2) << C1 into (X << C1) {&,^,|} (C2 << C1)
84ff66b884e9 (Andre Vieira             2015-10-09 16:08:35 +0000 3952)    (X
{&,^,|} C2) >> C1 into (X >> C1) & (C2 >> C1).  */
98e30e515f18 (Richard Biener           2015-07-07 14:12:44 +0000 3953) (for
shift (lshift rshift)
84ff66b884e9 (Andre Vieira             2015-10-09 16:08:35 +0000 3954)  (for
bit_op (bit_and bit_xor bit_ior)
84ff66b884e9 (Andre Vieira             2015-10-09 16:08:35 +0000 3955)  
(simplify
84ff66b884e9 (Andre Vieira             2015-10-09 16:08:35 +0000 3956)   
(shift (convert?:s (bit_op:s @0 INTEGER_CST@2)) INTEGER_CST@1)
84ff66b884e9 (Andre Vieira             2015-10-09 16:08:35 +0000 3957)    (if
(tree_nop_conversion_p (type, TREE_TYPE (@0)))
84ff66b884e9 (Andre Vieira             2015-10-09 16:08:35 +0000 3958)    
(with { tree mask = int_const_binop (shift, fold_convert (type, @2), @1); }
39f5e9aded23 (Jakub Jelinek            2020-11-26 10:50:23 +0100 3959)      (if
(mask)
39f5e9aded23 (Jakub Jelinek            2020-11-26 10:50:23 +0100 3960)      
(bit_op (shift (convert @0) @1) { mask; })))))))

Oh I should mention shifts is always INTEGER_CST, so only @2 needs to be
checked here.

Reply via email to