https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109112
Bug ID: 109112 Summary: [missed optimization] odd behaviour with [[assume(...)]] and member variables Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ivan.lazaric.gcc at gmail dot com Target Milestone: --- Everything is built with flags: -std=c++23 -O3 [[assume(...)]] doesn't seem to work quite as well when dealing with member variables. First version of `fn`: void do_something(); void fn(bool x){ [[assume(!x)]]; if (x) do_something(); } `fn` compiles into nothing: fn(bool): ret Second version of `fn`, wrapping the `bool` argument in a simple struct: struct S { bool x; }; void do_something(); void fn(S s){ [[assume(!s.x)]]; if (s.x) do_something(); } This no longer compiles into just `ret`: fn(S): test dil, dil jne .L5 ret .L5: jmp do_something() Expected behaviour was for `fn(S)` to reduce to just `ret` Godbolt link with the examples: https://godbolt.org/z/nreM4Y6dW