https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101543
Bug ID: 101543 Summary: extra zeroing of empty struct argument/return value Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Target: aarch64-linux-gnu Take: struct Tag { friend Tag make_tag(); private: Tag() {} }; Tag make_tag() { return Tag{}; }; void needs_tag(Tag); void foo1(void) { Tag t = make_tag(); needs_tag(t); } struct Tag1 {}; struct Tag2 {}; struct Tag3 {}; struct Tag4 {}; struct Tag5 {}; void needs_tags(int x, Tag1 t1, Tag2 t2, Tag3 t3, Tag4 t4, Tag5 t5, int y); void foo2(Tag1 t1, Tag2 t2, Tag3 t3, Tag4 t4, Tag5 t5) { needs_tags(12345, t1, t2, t3, t4, t5, t6, t7,t8, 200); } ---- CUT --- In make_tag the return register does not need to be zerod. In foo1, the argument x0 does not need to be zeroed before passing to needs_tag. In foo2, argument registers x1-x5 don't need to have been zeroed before passing to needs_tags.