@@ -991,6 +991,18 @@ static unsigned getSegInstNF(unsigned Intrinsic) {
991991 }
992992}
993993
994+ static bool isApplicableToPLI (int Val) {
995+ // Check if the immediate is packed i8 or i10
996+ int16_t Bit31To16 = Val >> 16 ;
997+ int16_t Bit15To0 = Val;
998+ int8_t Bit15To8 = Bit15To0 >> 8 ;
999+ int8_t Bit7To0 = Val;
1000+ if (Bit31To16 != Bit15To0)
1001+ return false ;
1002+
1003+ return isInt<10 >(Bit31To16) || Bit15To8 == Bit7To0;
1004+ }
1005+
9941006void RISCVDAGToDAGISel::Select (SDNode *Node) {
9951007 // If we have a custom node, we have already selected.
9961008 if (Node->isMachineOpcode ()) {
@@ -1034,12 +1046,12 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
10341046 if (!isInt<32 >(Imm) && isUInt<32 >(Imm) && hasAllWUsers (Node))
10351047 Imm = SignExtend64<32 >(Imm);
10361048
1037- if (hasAllWUsers (Node) && Subtarget-> hasStdExtP ( ) &&
1038- Subtarget->enablePExtCodeGen ()) {
1049+ if (hasAllWUsers (Node) && isApplicableToPLI (Imm ) &&
1050+ Subtarget->hasStdExtP () && Subtarget-> enablePExtCodeGen ()) {
10391051 // If its 4 packed 8 bit integer or 2 packed signed integer, we can simply
10401052 // copy lower 32 bits to higher 32 bits to make it able to rematerialize
10411053 // to PLI_B or PLI_H
1042- Imm = (Imm << 32 ) | (Imm & 0xFFFFFFFF );
1054+ Imm = (( uint64_t ) Imm << 32 ) | (Imm & 0xFFFFFFFF );
10431055 }
10441056
10451057 ReplaceNode (Node, selectImm (CurDAG, DL, VT, Imm, *Subtarget).getNode ());
0 commit comments