A loop wasn't recognized as a memcpy because the load was thought to
potentially alias with the store. We should ignore memory operations to
constant memory since moving instructions around cannot change their
results.
Details
- Reviewers
lebedev.ri nikic
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp | ||
---|---|---|
881 | just return true; (no else) |
llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp | ||
---|---|---|
881 | then the newly introduced if condition is useless if we always return true |
llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp | ||
---|---|---|
881 | yeah, oh! sorry:) |
While this works, I don't think this really addresses the root problem of D101017. Your example already folds fine with -globals-aa -loop-idiom. If GlobalsAA is not available at the time LoopIdiom runs, then that's a bug...
llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp | ||
---|---|---|
876 | Without looking at the users of this function, just going by the contract on the function, I think you can only do this if Access is Mod (as you can't write to constant memory), but not if Access is Ref or ModRef. |
oh you're right, for some reason I thought this transform wasn't happening even with globals-aa
Without looking at the users of this function, just going by the contract on the function, I think you can only do this if Access is Mod (as you can't write to constant memory), but not if Access is Ref or ModRef.