[llvm-dev] Well-formed @llvm.lifetime.start and @llvm.lifetime.end intrinsics
Michael Kruse via llvm-dev
llvm-dev at lists.llvm.org
Fri Mar 31 04:48:47 PDT 2017
2017-03-31 3:38 GMT+02:00 Daniel Berlin <dberlin at dberlin.org>:
> Sure, and you definitely can't transform an unconditional store to a
> conditional one unless the uses are guarded by the same condition, or you
> can prove it already had that value (in which case, the memset would also be
> dead) :)
>
> ie
> memset(a, 0)
> use a
>
> can't be transformed to
> if (c)
> memset(a, 0)
> use a
>
> So again, if polly is making a lifetime.start conditional when the use is
> not conditional, that's a bug in polly, regardless of the bug in stack
> coloring's ability to handle it.
InstCombine transforms memset(a,1) to a single StoreInst, but keeps
the memset if the size argument is zero. A StoreInst can be optimized
away, e.g. by DeadStoreElimination. I wonder, are the semantics of
memset(a, 0) different than "do nothing"?
Where is the chain of transformations
memset(&a, '0', sizeof a);
if (c)
a = 1;
=>
if (c) {
memset(&a, '0', sizeof a);
a = 1;
} else
memset(&a, '0', sizeof a);
=>
if (c) {
memset(&a, '0', sizeof a);
a = 1;
} else
memset(&a, '0', sizeof a);
=>
if (c) {
a = 0;
a = 1;
} else
memset(&a, '0', sizeof a);
=>
if (c)
a = 1;
else
memset(&a, '0', sizeof a);
=>
if (c)
a = 0;
if (!c)
memset(&a, '0', sizeof a);
not legal?
Michael
More information about the llvm-dev
mailing list