https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116651
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |ASSIGNED Last reconfirmed| |2025-08-28 Ever confirmed|0 |1 Resolution|DUPLICATE |--- Component|middle-end |tree-optimization Severity|normal |enhancement Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- . For the simplified version of: ``` #include<vector> using namespace std; using T = int; bool test1(const std::vector<int>& in) { return in == std::vector<int>{42}; } ``` We don't fold __builtin_memcmp until it is too late and then we don't optimize way the extra load. That is the strlen pass is way too late. I will look into this further. ``` bool test1(const std::vector<std::string_view>& in) { return in == std::vector<std::string_view>{"*"}; } ``` is much more complex. There is a missed optimization dealing: ``` _12 = _10 - _11; if (_12 == 16) goto <bb 10>; [34.00%] else goto <bb 9>; [66.00%] ... <bb 10> [local count: 364780225]: if (_10 != _11) goto <bb 3>; [96.34%] else goto <bb 8>; [3.66%] ``` if `_10 - _11` is 16 then obviously `_10 != _11`. And then we somehow lose that the loop back-edge: ``` # __first1_13 = PHI <__first1_45(6), _11(9)> ... <bb 6> [local count: 74161852]: __first1_45 = __first1_13 + 16; __first2_46 = __first2_58 + 16; if (_10 != __first1_45) goto <bb 3>; [96.34%] else goto <bb 7>; [3.66%] ``` Only iterates once.