https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115499
Bug ID: 115499 Summary: Missed optimization: Fold (a ^ (b || c)) && c to (a ^ 1) && c Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: zhiwuyazhe154 at gmail dot com Target Milestone: --- godbolt example: https://godbolt.org/z/bjPnrTP7o Code example: ``` #include <algorithm> unsigned long long int m, n; void fn1(short a, unsigned long long int b, short c) { n = (a ^ (m || c)) && c; } void fn2(short a, unsigned long long int b, short c) { b = m; n = (a ^ (b || c)) && c; } void fn3(short a, unsigned long long int b, short c) { n = (a ^ (b || c)) && c; } ``` In fact, these three functions are equivalent((a ^ 1) && c), but the processing of the global variable m or the input parameter b by fn2 and fn3 leads to the lack of arithmetic optimization.