Apparently my PR91680 fix caused ICE on powerpc64le on Linux kernel (and possibly other architectures). Simple testcase: unsigned long long foo (unsigned long long x, unsigned long long y, int z) { return (x + y) / (1 << z); }
Created attachment 46864 [details] gcc10-pr91725.patch Untested fix.
(In reply to Jakub Jelinek from comment #1) > gcc10-pr91725.patch An alternative (I don't claim it is better) would be to make get_nonzero_bits conservatively return -1 on unknown input, like the comment before it seems to suggest.
Created attachment 46866 [details] gcc10-pr91725.patch Yet another untested patch, tree_nonzero_bits is something that already does what you write above, just doesn't cope with vector types (as it uses TYPE_PRECISION rather than element_precision). But, get_nonzero_bits isn't really useful on vector types anyway, for SSA_NAMEs we don't track the non-zero bits and for VECTOR_CSTs we'd need to test all elements and or the bits together.
Author: jakub Date: Wed Sep 11 08:33:55 2019 New Revision: 275633 URL: https://gcc.gnu.org/viewcvs?rev=275633&root=gcc&view=rev Log: PR middle-end/91725 * match.pd ((A / (1 << B)) -> (A >> B)): Call tree_nonzero_bits instead of get_nonzero_bits, only call it for integral types. * gcc.c-torture/compile/pr91725.c: New test. Added: trunk/gcc/testsuite/gcc.c-torture/compile/pr91725.c Modified: trunk/gcc/ChangeLog trunk/gcc/match.pd trunk/gcc/testsuite/ChangeLog
Fixed.
*** Bug 91743 has been marked as a duplicate of this bug. ***