https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97325
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:600cf1128e49f086522bfddc54490b4e39e30383 commit r11-3743-g600cf1128e49f086522bfddc54490b4e39e30383 Author: Jakub Jelinek <ja...@redhat.com> Date: Fri Oct 9 10:16:57 2020 +0200 match.pd: Fix up FFS -> CTZ + 1 optimization [PR97325] And no testcase was included, I'm including one below. Anyway, this PR and the other CTZ related discussions led me to discover a bug I've made earlier, CLZ/CTZ builtins have unsigned arguments and e.g. both the vr-values.cc and now gimple-range.cc code heavily relies on that, but __builtin_ffs has a signed operand and this optimization was incorrectly making the operand signed too, so I guess it would greatly confuse VRP in some cases. 2020-10-09 Jakub Jelinek <ja...@redhat.com> PR tree-optimization/97325 * match.pd (FFS(nonzero) -> CTZ(nonzero) + 1): Cast argument to corresponding unsigned type. * gcc.c-torture/execute/pr97325.c: New test.