[Bug tree-optimization/113676] [12 Regression] Miscompilation tree-vrp __builtin_unreachable

2024-01-31 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113676

--- Comment #4 from Jakub Jelinek  ---
And with --param=vrp1-mode=vrp it segfaulted even with
r13-4276-gce917b0422c145779b83e005afd8433c0c86fb06 but the next revision
removed that parameter, so can't go further.

[Bug tree-optimization/113676] [12 Regression] Miscompilation tree-vrp __builtin_unreachable

2024-01-31 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113676

Jakub Jelinek  changed:

   What|Removed |Added

 CC||aldyh at gcc dot gnu.org,
   ||amacleod at redhat dot com,
   ||jakub at gcc dot gnu.org
   Keywords|needs-bisection |

--- Comment #3 from Jakub Jelinek  ---
Bisection with -O2 -ftree-vrp
#include 

unsigned
bit_ceil (unsigned x)
{
  if (x <= 1)
return 1U;
  int w = 32 - __builtin_clz (x - 1);
  return 1U << w;
}

int
main (int argc, char **)
{
  unsigned rounded_n = bit_ceil ((unsigned) (argc + 1));
  auto a = std::vector (2UL * rounded_n);
  for (long unsigned int i = rounded_n; i-- > 1;)
{
  if (!(0 < i && i < rounded_n))
__builtin_unreachable();
  a[i] = 0;
}
}
shows this started with r12-155-gd8e1f1d24179690fd9c0f63c27b12e030010d9ea
and went away with r13-3596-ge7310e24b1c0ca67b1bb507c1330b2bf39e59e32
so nothing really backportable.

[Bug tree-optimization/113676] [12 Regression] Miscompilation tree-vrp __builtin_unreachable

2024-01-31 Thread magnus.hegdahl at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113676

--- Comment #2 from Magnus Hokland Hegdahl  ---
Hi, here's a version that doesn't need -std=c++20 or argv:

https://godbolt.org/z/Y9ooY998e

#include 

constexpr auto bit_ceil(unsigned x) -> unsigned {
if (x <= 1) return 1U;
int w = 32 - __builtin_clz(x - 1);
return 1U << w;
}

int main(int argc, char **) {
auto rounded_n = bit_ceil(static_cast(argc + 1));
auto a = std::vector(2UL * rounded_n);

for (std::size_t i = rounded_n; i-- > 1;) {
if (!(0 < i && i < rounded_n)) __builtin_unreachable();
a[i] = 0;
}
}

Exact compile command used with g++-12 (GCC) 12.3.0 on arch linux, x86_64:
g++-12 -O1 -ftree-vrp main.cpp

[Bug tree-optimization/113676] [12 Regression] Miscompilation tree-vrp __builtin_unreachable

2024-01-31 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113676

Richard Biener  changed:

   What|Removed |Added

 Target||x86_64-*-*
Summary|[11/12 Regression]  |[12 Regression]
   |Miscompilation tree-vrp |Miscompilation tree-vrp
   |__builtin_unreachable   |__builtin_unreachable

--- Comment #1 from Richard Biener  ---
Needs -std=c++20.  I can't reproduce locally.