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

            Bug ID: 127638
           Summary: bitintlower increases alignment requirements
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kristerw at gcc dot gnu.org
            Blocks: 118443
  Target Milestone: ---

bitintlower incorrectly increases alignment requirements when compiling the
function below for x86_64 with -O2:

void
foo (void *p, _BitInt(246) x)
{
  __builtin_memcpy (p, &x, sizeof x);
}

bitintlower transforms this into four 64-bit load/store instructions:

  _5 = MEM <unsigned long> [(_BitInt(246) *)&x];
  MEM <unsigned long> [(char * {ref-all})p_3(D)] = _5;
  _6 = MEM <unsigned long> [(_BitInt(246) *)&x + 8B];
  MEM <unsigned long> [(char * {ref-all})p_3(D) + 8B] = _6;
  ...

The stores require 8-byte alignment, which is incorrect because p may be
unaligned.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118443
[Bug 118443] [Meta bug] Bugs triggered by and blocking more smtgcc testing

Reply via email to