This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Fix bug in AArch64RedundantCopyElimination removing COPYs it shouldn't.
AbandonedPublic

Authored by gberry on Feb 10 2017, 2:28 PM.

Details

Summary

Don't remove COPYs with implicit defs, unless we know the implicitly
defined register is also zero.

Event Timeline

gberry created this revision.Feb 10 2017, 2:28 PM
t.p.northover edited edge metadata.Feb 10 2017, 2:50 PM

Where do copies like that come from? It seems like a pretty sketchy target-specific extension to a shared instruction, and we should probably be representing that in some better way.

MatzeB edited edge metadata.Feb 10 2017, 3:05 PM

Where do copies like that come from? It seems like a pretty sketchy target-specific extension to a shared instruction, and we should probably be representing that in some better way.

Indeed a COPY instruction does not necessarily clear the upper bits of a register, even if the targets move instruction to implement it does. This mostly comes from the fact that we are allowed to eliminate NOP copies when the source and target are the same, with the rule to clear the upper bits we would not longer be allowed to do so.

junbuml added inline comments.Feb 13 2017, 8:01 AM
test/CodeGen/AArch64/machine-copy-remove.mir
24

Why not adding the below case as well in the test ?

%w0 = COPY %wzr, implicit-def %x0
gberry abandoned this revision.Feb 15 2017, 10:29 AM

Yeah, it looks like this was a false alarm. I spot checked some of the cases that were leading to these COPYs and all of them were of the form:

%vreg:sub_32<def,read-undef> = COPY %WZR

which don't expect to have the upper 32 bits cleared.