This is an archive of the discontinued LLVM Phabricator instance.

[MIPS][SelectionDAG] Enable TargetLowering::hasBitTest for masks that fit in ANDI.
ClosedPublic

Authored by Miss_Grape on Apr 12 2022, 2:17 AM.

Diff Detail

Event Timeline

Miss_Grape created this revision.Apr 12 2022, 2:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2022, 2:17 AM
Miss_Grape requested review of this revision.Apr 12 2022, 2:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2022, 2:17 AM

TODO: add test cases

Miss_Grape retitled this revision from WIP [MIPS][SelectionDAG] Enable TargetLowering::hasBitTest for masks that fit in ANDI. to [MIPS][SelectionDAG] Enable TargetLowering::hasBitTest for masks that fit in ANDI..

Add test

sdardis added inline comments.Apr 18 2022, 4:56 PM
llvm/lib/Target/Mips/MipsISelLowering.cpp
1178

Add a comment here:

// For MIPSR2 or later, we may be able to use the `ext` instruction or its' double-word variants.
1179

I believe this code would be clearer if it was the likes of:

if (auto *C = dyn_Cast<ConstantSDNode>(Y))
  return C->getAPIntValue().ule(14);

return false;

Also, the 14 should be 15 here. andi takes a 16-bit immediate.

Fix the comment

Miss_Grape marked an inline comment as done.Apr 19 2022, 6:51 PM
Miss_Grape added inline comments.
llvm/lib/Target/Mips/MipsISelLowering.cpp
1179

This number represents the shift, As shown below

Miss_Grape retitled this revision from [MIPS][SelectionDAG] Enable TargetLowering::hasBitTest for masks that fit in ANDI. to [WIP][MIPS][SelectionDAG] Enable TargetLowering::hasBitTest for masks that fit in ANDI..Apr 19 2022, 7:02 PM

1,address comment

Miss_Grape retitled this revision from [WIP][MIPS][SelectionDAG] Enable TargetLowering::hasBitTest for masks that fit in ANDI. to [MIPS][SelectionDAG] Enable TargetLowering::hasBitTest for masks that fit in ANDI..Apr 19 2022, 7:36 PM
Miss_Grape added inline comments.
llvm/lib/Target/Mips/MipsISelLowering.cpp
1179

Sorry, the immediate range of the and instruction of Mips is uimm6 instead of sim16. I have fixed and corrected the test case

Miss_Grape marked an inline comment as done.Apr 19 2022, 7:37 PM
sdardis accepted this revision.Apr 24 2022, 10:49 AM

LGTM.

This revision is now accepted and ready to land.Apr 24 2022, 10:49 AM
This revision was landed with ongoing or failed builds.Apr 27 2022, 2:04 AM
This revision was automatically updated to reflect the committed changes.