[Bug c++/82325] worse code generated compared to clang when using a constexpr array

dvd at gnx dot it gcc-bugzilla@gcc.gnu.org
Tue Sep 26 08:58:00 GMT 2017


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

--- Comment #2 from David <dvd at gnx dot it> ---
(In reply to Jakub Jelinek from comment #1)
> To unroll the loop completely with gcc, one needs to use --param
> max-completely-peel-times=32 because the loop has more than 16 iterations,
> which is the default limit for the complete unrolling.

Thanks! change the param to 32 did the trick (even if the resulting code is
larger than the one produced by clang)

> That said, neither of the compilers figures out that after unrolling the
> intervals are really adjacent, but disjoint, it would be much better to
> build a binary decision tree rather than a loop from smallest to largest.
> But you can handle that at the source level by doing a binary search in the
> array (and you could as well ignore bits there too, just look at the base
> values).

The rewrite as a binary search result a more compact code, I'll profile it to
understand if it will be also faster.

Do you prefer to keep this bug open or can I mark it as resolved?


More information about the Gcc-bugs mailing list