https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81248
Bug ID: 81248 Summary: [AVR] No ipa-sra optimization for small struct / class Product: gcc Version: 7.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: wilhelm.me...@hs-kl.de Target Milestone: --- In the following minimal example, avr-g++ optimizes the call of f(n1) with ipa-sra, that is it replaces the pointer-registers with a value-register. The same should be possible for f(n2), but in this case avr-g++ doesn't make the same optimization. #include <cstdint> #include <type_traits> struct A { A() = default; A(const A& o) = default; A(const volatile A& o) : m1(o.m1) {} uint8_t m1{0}; }; volatile uint8_t v; template<typename T> void f(const T& x) __attribute__((noinline)); template<typename T> void f(const T& x) { if constexpr(std::is_same<std::remove_cv_t<T>, A>::value) { v = x.m1; } else { v = x; } } uint8_t n1; A n2; int main() { f(n1); f(n2); }