https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82888
--- Comment #3 from Nathan Froyd <froydnj at gcc dot gnu.org> --- Thanks, I didn't think to test -O3. Do we get the memset at -O3 because loop idiom recognition is enabled? Producing the memset upfront probably generates better code for all cases, even if the frontend code is a little more complicated.