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

--- Comment #8 from Drea Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Souradipto Das from comment #7)
> Created attachment 64567 [details]
> v2 patch: Captures zero via native match.pd variables instead of C++ code,
> and adds testcases for both AND/OR reduction paths.
> 
> Thanks for the discussion, Kael! 
> 
> I've attached a v2 patch that handles both the OR and AND cases using a
> clean macro iterator loop in match.pd. It captures the zero constant using
> native variable tracking (`integer_zerop@2`) instead of dropping into an
> explicit C++ block, which keeps the code much cleaner.
> 
> I also updated the testcase at gcc.dg/pr125442.c to make sure both paths
> optimize down perfectly on x86_64-pc-linux-gnu. Let me know what you think!

Note you can capture the original `(neeq @0 integer_zerop@2)` and use that
(e.g. `(neeq@2 @0 integer_zerop)` and use @2 as the result). In this case it is
better to do so as it will do that later on in FRE and others passes anyways.

Reply via email to