[PATCH] D123577: [MIPS][SelectionDAG] Enable TargetLowering::hasBitTest for masks that fit in ANDI.
Simon Dardis via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 18 16:56:28 PDT 2022
sdardis added inline comments.
================
Comment at: llvm/lib/Target/Mips/MipsISelLowering.cpp:1178
+bool MipsTargetLowering::hasBitTest(SDValue X, SDValue Y) const {
+ // We can use ANDI+SLTIU as a bit test. Y contains the bit position.
+ auto *C = dyn_cast<ConstantSDNode>(Y);
----------------
Add a comment here:
```
// For MIPSR2 or later, we may be able to use the `ext` instruction or its' double-word variants.
```
================
Comment at: llvm/lib/Target/Mips/MipsISelLowering.cpp:1179
+ // We can use ANDI+SLTIU as a bit test. Y contains the bit position.
+ auto *C = dyn_cast<ConstantSDNode>(Y);
+ return C && C->getAPIntValue().ule(14);
----------------
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.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123577/new/
https://reviews.llvm.org/D123577
More information about the llvm-commits
mailing list