Bug 14593 - [tree-ssa] bcopy is mysteriously replaced with memcpy
Summary: [tree-ssa] bcopy is mysteriously replaced with memcpy
Status: RESOLVED DUPLICATE of bug 14197
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: tree-ssa
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-16 04:32 UTC by Kazu Hirata
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target: h8300-elf
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kazu Hirata 2004-03-16 04:32:53 UTC
Reduced from gcc.c-torture/execute/builtins/string-asm-2*

typedef __SIZE_TYPE__ size_t;
extern void abort (void);
extern void bcopy (const void *, void *, size_t);

char y[64] = "foX";

void *
memcpy (void *d, const void *s, size_t n)
{
  char *dst = (char *) d;
  const char *src = (const char *) s;
  while (n--)
    *dst++ = *src++;
  return (char *) d;
}

int
main (void)
{
  bcopy (y + 1, y + 2, 3);
  if (y[3] != 'X')
    abort ();

  return 0;
}

With -O0, bcopy stays as is in the final assembly output.
With -O1 and above, bcopy is somehow transformed into memcpy.

This problem seems to occur at expand-time.

On mainline, this problem does not exist.
Comment 1 Kazu Hirata 2004-03-16 04:34:06 UTC
Note that on this testcase, bcopy must stay as is because
source and destination of bcopy overlap.
Comment 2 Andrew Pinski 2004-03-16 04:43:58 UTC
This is an almost exact (very close in fact references the same test case even) dup of bug 14197.

*** This bug has been marked as a duplicate of 14197 ***