Okay so far I got around this using clang's __builtin_assume
to enforce that (i * n + j) % n
is always j
when j < n
, and together with -O2
it works perfectly. I guess when C++23 is ready we could do the same using the [[assume(...)]]
attribute.
this post was submitted on 23 Aug 2023
9 points (100.0% liked)
C++
1783 readers
1 users here now
The center for all discussion and news regarding C++.
Rules
- Respect instance rules.
- Don't be a jerk.
- Please keep all posts related to C++.
founded 1 year ago
MODERATORS
You can already feature-test for assume (or gnu::assume) without C++23. See: https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#testing-for-the-presence-of-an-attribute-__has_cpp_attribute