public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/73457] Missed optimizations: count_if on std::array of constants.
       [not found] <bug-73457-4@http.gcc.gnu.org/bugzilla/>
@ 2021-08-18 21:57 ` pinskia at gcc dot gnu.org
  2021-08-18 22:25 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-18 21:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
testcase:
#include <array>
#include <algorithm>

enum event {
  stuff,
  crap
};

template<typename Cont>
auto count_event(event e, Cont const& events) {
        return std::count(events.begin(), events.end(), e);
}

int main() {
  std::array<event, 4> events = { stuff, crap, stuff, stuff };
  return count_event(stuff, events);
}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug tree-optimization/73457] Missed optimizations: count_if on std::array of constants.
       [not found] <bug-73457-4@http.gcc.gnu.org/bugzilla/>
  2021-08-18 21:57 ` [Bug tree-optimization/73457] Missed optimizations: count_if on std::array of constants pinskia at gcc dot gnu.org
@ 2021-08-18 22:25 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-18 22:25 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
GCC 8+ can handle this at -O3 and above because we can vectorize the loop
(which GCC 7 could not do, I have not looked into why) so DOM is able to
optimize it after unrolling.

GCC 10+ can handle this at -O3 -fno-tree-loop-vectorize (with SLP still
happening) because of r10-1420.


I do think we should be able to optimize this for -O2 though.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-18 22:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-73457-4@http.gcc.gnu.org/bugzilla/>
2021-08-18 21:57 ` [Bug tree-optimization/73457] Missed optimizations: count_if on std::array of constants pinskia at gcc dot gnu.org
2021-08-18 22:25 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).