LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 452 - memset/memcpy analysis/optimizations need improving
Summary: memset/memcpy analysis/optimizations need improving
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Interprocedural Optimizations (show other bugs)
Version: trunk
Hardware: All All
: P enhancement
Assignee: Unassigned LLVM Bugs
URL:
Keywords: code-quality
Depends on: 2058 1226 1952 2059
Blocks:
  Show dependency tree
 
Reported: 2004-10-20 12:46 PDT by Brian R. Gaeke
Modified: 2009-04-22 04:37 PDT (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments
Edits a hard-coded string in an unrolled loop (752 bytes, text/x-c++src)
2007-04-05 16:57 PDT, Mathias Gaunard
Details
example with poor memcpy optimization (345 bytes, text/plain)
2008-01-28 23:55 PST, Duncan Sands
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brian R. Gaeke 2004-10-20 12:46:06 PDT
Just so this doesn't get lost, I'm filing a "wishlist" item for this.

Date: Wed, 6 Oct 2004 14:25:30 -0500 (CDT)
From: Chris Lattner <sabre@nondot.org>
Subject: memset optimizations

memset currently inhibits multiple optimizations, e.g. memset/load doesn't
get copy-propagated, memset doesn't cause dead stores to die, and memset
inhibits SRA.  This should be fixed!

Also: memset(&X, 4) -> store int 0, X   iff X is aligned

Also, memset should not kill unaliased loads/stores.
Comment 1 Mathias Gaunard 2007-04-05 16:57:46 PDT
Created attachment 759 [details]
Edits a hard-coded string in an unrolled loop

I was told in the IRC channel that the non optimized LLVM code I was getting of
the attached C++ code was related to this issue.
It becomes optimized when the string 's' becomes small, like "this".
Comment 2 Chris Lattner 2007-04-08 19:57:19 PDT
Bug 1309 is also related to this.
Comment 3 Duncan Sands 2008-01-28 23:55:17 PST
Created attachment 1358 [details]
example with poor memcpy optimization

In the last line
        return r + x.A;
the value of x.A is zero, but LLVM doesn't understand this.
Presumably this is because it thinks memcpy has modified x,
even though it copies from x and not to it.
Comment 4 Chris Lattner 2008-01-28 23:58:15 PST
Bug 1952 is one specific optimization that we can do, relating it.
Comment 5 Owen Anderson 2008-04-09 03:27:16 PDT
This has gotten a lot better recently, with work Chris and I have done which is now in the MemCpyOpt pass.  There's still a lot to do, though.
Comment 6 Owen Anderson 2009-04-22 04:37:27 PDT
I'm closing this open-ended bug, as we'll never catch EVERY case.  If you still have specific cases that you'd like to see addressed, please file individual PRs for them.