Skip to content

Commit de9c8ce

Browse files
committed
Make the lsb/msb arguments/variables to truly be least significant bit
and most significant bit of the insertion.
1 parent 27d670f commit de9c8ce

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,8 @@ bool RISCVDAGToDAGISel::tryUnsignedBitfieldInsertInZero(SDNode *Node, SDLoc DL,
699699
unsigned Opc = RISCV::NDS_BFOZ;
700700

701701
SDNode *Ubi = CurDAG->getMachineNode(Opc, DL, VT, X,
702-
CurDAG->getTargetConstant(Msb, DL, VT),
703-
CurDAG->getTargetConstant(Lsb, DL, VT));
702+
CurDAG->getTargetConstant(Lsb, DL, VT),
703+
CurDAG->getTargetConstant(Msb, DL, VT));
704704
ReplaceNode(Node, Ubi);
705705
return true;
706706
}
@@ -1348,13 +1348,10 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
13481348
// e.g.
13491349
// (and (shl x, 12), 0x00fff000)
13501350
// If XLen = 32 and C2 = 12, then
1351-
// Len = 32 - 8 - 12 = 12,
1352-
// Lsb = 32 - 8 - 1 = 23 and Msb = 12
1353-
// -> nds.bfoz x, 12, 23
1354-
const unsigned Len = XLen - Leading - C2;
1355-
const unsigned Lsb = XLen - Leading - 1;
1356-
// If Len is 1, the Msb will be 0 instead of C2.
1357-
unsigned Msb = Len == 1 ? 0 : C2;
1351+
// Msb = 32 - 8 - 1 = 23 and Lsb = 12
1352+
const unsigned Msb = XLen - Leading - 1;
1353+
// If Msb is equal to C2, the Lsb will be 0 instead of C2.
1354+
unsigned Lsb = Msb == C2 ? 0 : C2;
13581355
if (tryUnsignedBitfieldInsertInZero(Node, DL, VT, X, Msb, Lsb))
13591356
return;
13601357

0 commit comments

Comments
 (0)