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

--- Comment #20 from Richard Biener <rguenth at gcc dot gnu.org> ---
So while I managed to create a PRE mixed alignment testcase I failed sofar to
create a testcase for the alias-set handling we have (but IIRC never had a
testcase for).  Sth like

typedef short __attribute__((may_alias)) sp;

short __attribute__((noipa))
foo (bool aligned, bool write, int *p)
{
  if (write)
    *p = 0;
  short tem;
  if (aligned)
    tem = *((sp *)p);
  else
    tem = *((short *)p);
  return tem;
}

int main()
{
  int a = 0x01020304;
  if (foo (true, false, &a) != 0x0304)
    __builtin_abort ();
  return 0;
}

where PRE inserts on the else path on if (write), it should randomly select
either the short or sb TBAA variant and then there should be an opportunity
_after_ PRE to miscompile that, which means there has to be an upthread
store via 'int' visible in foo itself or possibly late modref make the
store in main() dead.  I have not managed PRE to trick into using the
'short' typed reference for insertion.

ANTIC_OUT[8] := { p_5(D) (0004), aligned_7(D) (0006), {mem_ref<(A16)(sp *
{ref-all})0B>,p_5(D)}@.MEM_4(D) (0007), {mem_ref<(A16)(short int
*)0B>,p_5(D)}@.MEM_4(D) (0007) }

Reply via email to