[BUG] DoNotOptimize() doesn't prevent gcc/clang from optimizing out array lookup
Open
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 1.8k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 8
Description
**Describe the bug**
`DoNotOptimize()` doesn't prevent gcc from optimizing out array lookup.
**System**
- x86, godbolt, gcc 12.1, clang 14.0.0, google benchmark 1.6.1
**To reproduce**
See assembly produced for this: https://godbolt.org/z/ahPss8hvY
On `clang -O2` everything is ok - addition and mov from `LUT` array
On `gcc -O2` - mov is missing
**Expected behavior**
`DoNotOptimize()` should prevent gcc from optimizing out array lookup
Edit: example minimisation
Contributor guide
Assessment
This issue has not been assessed yet.