https://llvm.org/bugs/show_bug.cgi?id=25559

            Bug ID: 25559
           Summary: [GVN] Should be able to PRE a load from memset
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: mcros...@codeaurora.org
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

Currently, GVN can pre loads from calloc like functions.  For example, in the
below test case the store to 'res' will be converted from a load into a
constant zero.

#include <strings.h>
#include <stdlib.h>

int *test_calloc(int n, int *res)
{
  if (n == 0)
    return 0;

  int *ptr = (int *)calloc(n, sizeof(int));
  *res = ptr[n-1];
  return ptr;
}

However, PRE falls apart with this example:

int *test_malloc_memset_zero(int n, int *res)
{
  if (n == 0)
    return 0;

  int *ptr = (int *)malloc(n * sizeof(int));
  bzero(ptr, n * sizeof(int));
  *res = ptr[n-1];
  return ptr;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to