This is an archive of the discontinued LLVM Phabricator instance.

[CGP] Update MemIntrinsic alignment if possible
ClosedPublic

Authored by arichardson on Sep 20 2022, 6:22 AM.

Details

Summary

Previously it was only being done if shouldAlignPointerArgs() returned
true, which right now is only true for ARM targets.
Updating the argument alignment attributes of memcpy/memset intrinsics
if the underlying object has larger alignment can be beneficial even
if CGP didn't increase alignment (as can be seen from the test changes),
so invert the loop and if condition.

Diff Detail

Event Timeline

arichardson created this revision.Sep 20 2022, 6:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 20 2022, 6:22 AM
arichardson requested review of this revision.Sep 20 2022, 6:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 20 2022, 6:22 AM
pengfei added inline comments.Sep 20 2022, 6:50 AM
llvm/lib/CodeGen/CodeGenPrepare.cpp
2227–2233

Re-format it.

llvm/test/CodeGen/X86/memset-2.ll
13–23

Not sure if the use of movaps is a good idea considering the test in below file.

llvm/test/CodeGen/X86/memset64-on-x86-32.ll
18–55

Are they intent to use movl/q here?

llvm/test/Transforms/CodeGenPrepare/X86/memset_chk-simplify-nobuiltin.ll
14 ↗(On Diff #461555)

No ATTR1 to match with it. Just removing the #1 instead?

arichardson added inline comments.Sep 20 2022, 8:10 AM
llvm/test/CodeGen/X86/memset-2.ll
13–23

I guess the real fix would be to not use null as the destination. I'm not sure what the test is actually checking, but I could change it to be an argument?

llvm/test/Transforms/CodeGenPrepare/X86/memset_chk-simplify-nobuiltin.ll
14 ↗(On Diff #461555)

Yeah will regen with --scrub-attributes

pengfei added inline comments.Sep 20 2022, 6:10 PM
llvm/test/CodeGen/X86/memset-2.ll
13–23

How about change 0 to 1?
With a read on the history, I think the intention was to make sure no movups generated. See rG7998b1d6f and rGa048c83fe47

llvm/test/CodeGen/X86/memset64-on-x86-32.ll
56

Ditto here. Change 0 to 4?

arichardson marked 5 inline comments as done.

Address feedback

arichardson added inline comments.Sep 27 2022, 7:20 AM
llvm/test/CodeGen/X86/memset-2.ll
13–23

I've added an argument instead of using null as the base - that seems to restore the previous behaviour of calling memset.

llvm/test/CodeGen/X86/memset64-on-x86-32.ll
18–55

Will change the null argument to a function input - this mostly restores the old codegen.

efriedma added inline comments.Oct 12 2022, 5:14 PM
llvm/lib/CodeGen/CodeGenPrepare.cpp
2254–2255

Is this change putting this code inside the for loop? We don't need to run this more than once per call.

arichardson marked an inline comment as done.

address review comment

arichardson marked an inline comment as done.Nov 16 2022, 8:46 AM
This revision is now accepted and ready to land.Nov 16 2022, 4:06 PM
This revision was landed with ongoing or failed builds.Nov 17 2022, 4:00 AM
This revision was automatically updated to reflect the committed changes.