Page MenuHomePhabricator

[SimplifyLibcalls] Memcpy + strlen propagation
AbandonedPublic

Authored by xbolva00 on Apr 12 2018, 3:50 PM.

Details

Reviewers
spatel
efriedma
Summary

Patch optimizes the following case:

unsigned memcpy_strlen (char *d) {

memcpy (d, "aaaa", 5);
// ...  
return strlen(d); //  optimize to 4

}

if between memcpy and strlen calls "d" is modified, transformation is not performed.

Diff Detail

Event Timeline

xbolva00 created this revision.Apr 12 2018, 3:50 PM
xbolva00 added reviewers: spatel, efriedma.
xbolva00 set the repository for this revision to rL LLVM.
xbolva00 updated this revision to Diff 142290.Apr 12 2018, 4:00 PM
xbolva00 updated this revision to Diff 142292.Apr 12 2018, 4:05 PM
xbolva00 updated this revision to Diff 142293.Apr 12 2018, 4:11 PM

GVN should already be able to get this, and if it can't, improve it's intrinsic handling (Either in VNCoercion's memory transfer intrinsic handling, or ...).

That's gonna do a lot better than trying to special case it in libcall simplification.
It also looks like you made it O(number of instructions) worst case per call?

GVN should already be able to get this, and if it can't, improve it's intrinsic handling (Either in VNCoercion's memory transfer intrinsic handling, or ...).

That's gonna do a lot better than trying to special case it in libcall simplification.
It also looks like you made it O(number of instructions) worst case per call?

Ok, so I will close this change. If you know GVN, check this case..

xbolva00 abandoned this revision.Apr 12 2018, 4:50 PM