https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93231
Bug ID: 93231 Summary: [10 Regression] ICEs since rr280132 Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- int ctz2 (int x) { static const char table[32] = { 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 }; return table[((int)((x & -x) * -0x077CB531)) >> 27]; } ICEs because unsigned HOST_WIDE_INT val = tree_to_uhwi (mulc); is used without checking that the INTEGER_CST fits into uhwi. If we don't want to support signed x, we should start the function by verification that inner_type is INTEGRAL_TYPE_P which is TYPE_UNSIGNED, if we do want to support even signed values, it needs to be tweaked differently. Similarly, int ctz3 (unsigned x) { static const char table[32] = { 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 }; return table[((unsigned)((x & -x) * 0x077CB531U)) >> -27]; } ICEs because -27 doesn't fit into uhwi. We should just punt if it doesn't. I'm also surprised by /* Check the array is not wider than integer type and the input is a 32-bit or 64-bit type. */ if (TYPE_PRECISION (type) > 32) return false; because the comment doesn't match what the check is doing, either you want an array with 32-bit or smaller elts, then the comment should match that, or you care about integers and then you should compare against TYPE_PRECISION (integer_type_node).