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

            Bug ID: 115291
           Summary: armv8-a GCC emits float32x2_t loads from uninitialized
                    stack
           Product: gcc
           Version: 14.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: akihiko.odaki at daynix dot com
  Target Milestone: ---

Run the following commands:
git clone https://gitlab.com/libeigen/eigen.git -b
38b9cc263bbaeb03ce408a4e26084543a6c0dedb
cat main.cpp <<'EOF'
#include "Eigen/Core"

auto f() -> Eigen::Matrix2f {
  return Eigen::Matrix2f::Zero();
}

auto g() -> Eigen::Vector2f {
  auto v = Eigen::Product(f(), Eigen::Vector2f::Zero());
  return v;
}
EOF

c++ -Ieigen -O1 -DNDEBUG main.cpp -S

Now main.s looks like:
        .arch armv8-a
        .file   "main.cpp"
        .text
        .align  2
        .global _Z1fv
        .type   _Z1fv, %function
_Z1fv:
.LFB13241:
        .cfi_startproc
        mov     x0, x8
        str     wzr, [x8]
        str     wzr, [x8, 4]
        str     wzr, [x8, 8]
        str     wzr, [x8, 12]
        ret
        .cfi_endproc
.LFE13241:
        .size   _Z1fv, .-_Z1fv
        .align  2
        .global _Z1gv
        .type   _Z1gv, %function
_Z1gv:
.LFB13246:
        .cfi_startproc
        sub     sp, sp, #16
        .cfi_def_cfa_offset 16
        mov     x0, x8
        movi    v30.2s, 0
        ldr     d31, [sp]
        fmul    v31.2s, v31.2s, v30.2s
        ldr     d29, [sp, 8]
        fmla    v31.2s, v29.2s, v30.2s
        str     d31, [x8]
        add     sp, sp, 16
        .cfi_def_cfa_offset 0
        ret
        .cfi_endproc
.LFE13246:
        .size   _Z1gv, .-_Z1gv
        .align  2
        .type   _GLOBAL__sub_I__Z1fv, %function
_GLOBAL__sub_I__Z1fv:
.LFB14439:
        .cfi_startproc
        ret
        .cfi_endproc
.LFE14439:
        .size   _GLOBAL__sub_I__Z1fv, .-_GLOBAL__sub_I__Z1fv
        .ident  "GCC: (GNU) 14.1.1 20240507 (Red Hat 14.1.1-1)"
        .section        .note.GNU-stack,"",@progbits

In _Z1gv, "ldr  d31, [sp]" loads values from nowhere.

Reply via email to