https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117287

            Bug ID: 117287
           Summary: [13/14/15 Regression] assume attribute related
                    miscompilation
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: build
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
                CC: amonakov at gcc dot gnu.org, jakub at gcc dot gnu.org,
                    pinskia at gcc dot gnu.org, rguenth at gcc dot gnu.org,
                    sjames at gcc dot gnu.org
        Depends on: 117249
  Target Milestone: ---

+++ This bug was initially created as a clone of Bug #117249 +++

C++
static inline bool
foo (unsigned x)
{
  return x == 4 || x == 5 || x == 9 || x == 10;
}

int v;

[[gnu::noipa]] void
bar (const char *p)
{
  if (p[0] != (v ? 'a' : 'b') || p[1])
    __builtin_abort ();
}

[[gnu::noipa]] void
baz (unsigned x)
{
  bool a = x == 5;
  [[assume (foo (x))]];
  bar (a ? "a" : "b");
}

int
main ()
{
  baz (4);
  v = 1;
  baz (5);
  v = 0;
  baz (9);
  baz (10);
}

is miscompiled on the trunk and 14/13 branches with -O2
--param=logical-op-non-short-circuit=0, the vrp1 pass decides to call bar
("b"); unconditionally, even when the assumption should result in [4,5][9,10]
range for x.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117249
[Bug 117249] [12/13/14/15 Regression] --disable-checking is broken since
r5-2450

Reply via email to