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

            Bug ID: 27209
           Summary: failure to optimize a simple loop to a memset call
                    (incorrect fear of aliasing?)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedb...@nondot.org
          Reporter: richard-l...@metafoo.co.uk
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

LLVM fails to optimize this simple loop to a memset:

void f(char *p, char *q) {
  for (char *r = q; r != q + 256; ++r) *r = *p;
}

Presumably the relevant optimization is not firing here because of fear that p
might alias some element of the array pointed at by q. However, that doesn't
matter, because *p is the only thing written to that array, and the store size
is the same as the alignment, so *p can never actually change as a result.

See also https://llvm.org/bugs/show_bug.cgi?id=27206 -- LLVM should at least be
able to optimize that if the type of the field within struct S is char, and
should be able to hoist the load of s.i out of the loop for any type where size
== alignment. (And using C++ object lifetime rules, the hoisting is always
permitted regardless of alignment.)

-- 
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