This is an archive of the discontinued LLVM Phabricator instance.

GlobalISel: Combine out redundant sext_inreg
ClosedPublic

Authored by arsenm on Aug 28 2020, 7:56 AM.

Details

Summary

The scalar tests don't work yet, since computeNumSignBits apparently
doesn't handle sextload yet, and sext folds into the load first.

Diff Detail

Event Timeline

arsenm created this revision.Aug 28 2020, 7:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 28 2020, 7:56 AM
arsenm requested review of this revision.Aug 28 2020, 7:56 AM

computeNumSignBits() does not mean that the value was sign extended. It only returns you the number of top-most bits that are known to be the same. As a result, this also ends up matching G_ZEXTLOAD which is a bug I hit in an earlier attempt at this.

computeNumSignBits() does not mean that the value was sign extended. It only returns you the number of top-most bits that are known to be the same. As a result, this also ends up matching G_ZEXTLOAD which is a bug I hit in an earlier attempt at this.

It is correct to match zextload though, you just know 1 fewer bit vs. sextload. It doesn't matter what the source is. This is exactly what DAGCombiner does: https://github.com/llvm/llvm-project/blob/master/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp#L11054

aemerson accepted this revision.Aug 28 2020, 10:45 AM

computeNumSignBits() does not mean that the value was sign extended. It only returns you the number of top-most bits that are known to be the same. As a result, this also ends up matching G_ZEXTLOAD which is a bug I hit in an earlier attempt at this.

It is correct to match zextload though, you just know 1 fewer bit vs. sextload. It doesn't matter what the source is. This is exactly what DAGCombiner does: https://github.com/llvm/llvm-project/blob/master/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp#L11054

Ah, I think the bug may have been an off by one issue then. So this combine can be deleted then: 64eb3a4915f0?

This revision is now accepted and ready to land.Aug 28 2020, 10:45 AM

computeNumSignBits() does not mean that the value was sign extended. It only returns you the number of top-most bits that are known to be the same. As a result, this also ends up matching G_ZEXTLOAD which is a bug I hit in an earlier attempt at this.

It is correct to match zextload though, you just know 1 fewer bit vs. sextload. It doesn't matter what the source is. This is exactly what DAGCombiner does: https://github.com/llvm/llvm-project/blob/master/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp#L11054

Ah, I think the bug may have been an off by one issue then. So this combine can be deleted then: 64eb3a4915f0?

computeNumSignBits() does not mean that the value was sign extended. It only returns you the number of top-most bits that are known to be the same. As a result, this also ends up matching G_ZEXTLOAD which is a bug I hit in an earlier attempt at this.

It is correct to match zextload though, you just know 1 fewer bit vs. sextload. It doesn't matter what the source is. This is exactly what DAGCombiner does: https://github.com/llvm/llvm-project/blob/master/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp#L11054

Ah, I think the bug may have been an off by one issue then. So this combine can be deleted then: 64eb3a4915f0?

Yes, I think so. I'll try to delete those after D86787