On Sun, 5 Nov 2023, Cassio Neri wrote:
When year_month_day_last::day() was implemented, Dr. Matthias Kretz realised
that the operation "& 1" wasn't necessary but we did not patch it at that
time. This patch removes the unnecessary operation.
Is there an entry in gcc's bugzilla about having the optimizer handle this
kind of optimization?
unsigned f(unsigned x){
if(x>=32)__builtin_unreachable();
return 30|(x&1); // --> 30|x
}
(that optimization would come in addition to your patch, doing the
optimization by hand is still a good idea)
It looks like the criterion would be a|(b&c) when the possible 1 bits of b
are included in the certainly 1 bits of a|c.
--
Marc Glisse