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

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2024-04-10 00:00:00         |2024-12-28
                 CC|                            |hubicka at gcc dot gnu.org

--- Comment #5 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
When push_back is visible to compiler as in suggested modified testcase:
#include <cstdlib>
#include <cstdint>

void push_back(uint32_t const&) __attribute__((noinline));

struct big_integer
{
    void push_back(uint32_t const&);
    size_t size;
    uint32_t* digits;
};

void big_integer::push_back(uint32_t const& a)
{
            __asm__("" : : : "memory");
                //__asm__("" : : "g"(&a) : "memory");
}

big_integer& operator*=(big_integer& a, uint32_t b)
{
    uint64_t const BASE = 1ull << 32;

    uint32_t carry = 0;
    for (size_t i = 0; i != a.size; i++)
    {
        uint64_t sum = 1ull * a.digits[i] * b + carry;
        carry = static_cast<uint32_t>(sum / BASE);
        a.digits[i] = static_cast<uint32_t>(sum % BASE);
    }

    if (carry)
    {
        a.push_back(carry);
        //a.push_back(uint32_t(carry));
    }

    return a;
}

modref now figures out that carry does not escape. Otherwise we are still
hitting the fact that PTA is not flow sensitive.

Reply via email to