alexfh wrote:

There's one more questionable effect of this commit (together with the fix in 
#89567). Some of our code started triggering "loop not unrolled" warnings. A 
reduced example is at https://godbolt.org/z/jG4xsGY7s
```
#include <cstddef>
#include <bit>

template <bool Flag>
int FailToBuild(int n) {
  constexpr int N = 100;
  auto init = [=]() { return Flag ? n : 0UL; };
  auto cond = [=](size_t ix) { return Flag ? ix != 0 : ix < 10; };
  auto iter = [=](size_t ix) {
    return Flag ? ix & ~(1ULL << std::countr_zero(ix)) : ix + 1;
  };
#pragma unroll Flag ? 1 : N
  for (size_t ix = init(); cond(ix); ix = iter(ix)) {
    n *= n;
  }
  return n;
}

int foo(int n) {
    return FailToBuild<true>(n);
}

int bar(int n) {
    return FailToBuild<false>(n);
}
```

`clang -std=c++20 -O3` started generating the following warning on this code 
after the commit:
```
<source>:13:3: warning: loop not unrolled: the optimizer was unable to perform 
the requested transformation; the transformation might be disabled or specified 
as part of an unsupported transformation ordering 
[-Wpass-failed=transform-warning]
   13 |   for (size_t ix = init(); cond(ix); ix = iter(ix)) {
```

It doesn't seem the generated code has actually changed, thus, the question is 
whether these are legit warnings that used to be missed, or vice versa?

https://github.com/llvm/llvm-project/pull/88666
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to