================
@@ -292,6 +292,11 @@ bool AddSubMulHelper(InterpState &S, CodePtr OpPC, 
unsigned Bits, const T &LHS,
   // If for some reason evaluation continues, use the truncated results.
   S.Stk.push<T>(Result);
 
+  // If wrapping is enabled, the new value is fine.
+  // FIXME: Pass this to the add/sub/mul op instead?
----------------
tbaederr wrote:

I was mainly thinking about performance implications.
For
```c++
constexpr bool inc2() {
        unsigned a = 0;

        for (unsigned i = 0; i != 1'000'000; ++i) {
                ++a;++a;++a;++a;
        }
        return true;
}

constexpr bool inc() {
        for (unsigned i = 0; i != 1'0; ++i) {
                inc2();
        }
        return true;
}
static_assert(inc());
```
Before:
```
Benchmark 1: bin/clang++ -c -std=c++23 ./inc.cpp -fconstexpr-steps=0
  Time (mean ± σ):      3.764 s ±  0.076 s    [User: 3.732 s, System: 0.015 s]
  Range (min … max):    3.705 s …  4.050 s    30 runs
```
After:
```
Benchmark 1: bin/clang++ -c -std=c++23 ./inc.cpp -fconstexpr-steps=0
  Time (mean ± σ):      3.828 s ±  0.115 s    [User: 3.796 s, System: 0.015 s]
  Range (min … max):    3.729 s …  4.337 s    30 runs
```

That is just a quick check though, I haven't measured what impact passing it as 
a flag would have.

https://github.com/llvm/llvm-project/pull/183761
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to