This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner] Add missing flag to addressing mode check
ClosedPublic

Authored by luismarques on Apr 5 2019, 5:38 AM.

Details

Summary

The DAGCombiner helper function canFoldInAddressingMode performs some checks for legal addressing modes, such as reg+imm. The TargetLowering::AddrMode struct used for that check should have the HasBaseReg field set to true to indicate the presence of a reg (other than the scale reg). The function did not set that field (and by default it's false). This patch corrects that oversight. No tests were impacted by the change, as the oversight did not seem to manifest as an actual problem at the moment.

Diff Detail

Repository
rL LLVM

Event Timeline

luismarques created this revision.Apr 5 2019, 5:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2019, 5:38 AM

Probably better to put it inside the branches for ADD/SUB, to make it clear that it's those specific operations that have a base register?

Given the current places we call canFoldInAddressingMode, and that the relevant targets are missing HasBaseReg checks (in particular, I looked at ARM and AArch64), I imagine it would be very hard to reproduce any effective change, yes. (Maybe you could come up with something for 32-bit ARM if you tried hard enough, but it's probably not worth bothering.)

asb accepted this revision.Apr 11 2019, 3:58 AM

With Eli's suggested change (sinking the assignment to the ADD/SUB branches), this seems good to me.

This revision is now accepted and ready to land.Apr 11 2019, 3:58 AM
This revision was automatically updated to reflect the committed changes.