@@ -1166,6 +1166,31 @@ static SDNode *selectI64ImmDirect(SelectionDAG *CurDAG, const SDLoc &dl,
1166
1166
return CurDAG->getMachineNode (PPC::RLDICL, dl, MVT::i64 , SDValue (Result, 0 ),
1167
1167
getI32Imm (Shift), getI32Imm (0 ));
1168
1168
}
1169
+ // 2-7) Patterns : High word == Low word
1170
+ // This may require 2 to 3 instructions, depending on whether Lo32 can be
1171
+ // materialized in 1 instruction.
1172
+ if (Hi32 == Lo32) {
1173
+ // Handle the first 32 bits.
1174
+ uint64_t ImmHi16 = (Lo32 >> 16 ) & 0xffff ;
1175
+ uint64_t ImmLo16 = Lo32 & 0xffff ;
1176
+ if (isInt<16 >(Lo32))
1177
+ Result =
1178
+ CurDAG->getMachineNode (PPC::LI8, dl, MVT::i64 , getI32Imm (ImmLo16));
1179
+ else if (!ImmLo16)
1180
+ Result =
1181
+ CurDAG->getMachineNode (PPC::LIS8, dl, MVT::i64 , getI32Imm (ImmHi16));
1182
+ else {
1183
+ InstCnt = 3 ;
1184
+ Result =
1185
+ CurDAG->getMachineNode (PPC::LIS8, dl, MVT::i64 , getI32Imm (ImmHi16));
1186
+ Result = CurDAG->getMachineNode (PPC::ORI8, dl, MVT::i64 ,
1187
+ SDValue (Result, 0 ), getI32Imm (ImmLo16));
1188
+ }
1189
+ // Use rldimi to insert the Low word into High word.
1190
+ SDValue Ops[] = {SDValue (Result, 0 ), SDValue (Result, 0 ), getI32Imm (32 ),
1191
+ getI32Imm (0 )};
1192
+ return CurDAG->getMachineNode (PPC::RLDIMI, dl, MVT::i64 , Ops);
1193
+ }
1169
1194
1170
1195
// Following patterns use 3 instructions to materialize the Imm.
1171
1196
InstCnt = 3 ;
@@ -1216,20 +1241,7 @@ static SDNode *selectI64ImmDirect(SelectionDAG *CurDAG, const SDLoc &dl,
1216
1241
return CurDAG->getMachineNode (PPC::RLDICL, dl, MVT::i64 , SDValue (Result, 0 ),
1217
1242
getI32Imm (TO), getI32Imm (LZ));
1218
1243
}
1219
- // 3-4) Patterns : High word == Low word
1220
- if (Hi32 == Lo32) {
1221
- // Handle the first 32 bits.
1222
- uint64_t ImmHi16 = (Lo32 >> 16 ) & 0xffff ;
1223
- unsigned Opcode = ImmHi16 ? PPC::LIS8 : PPC::LI8;
1224
- Result = CurDAG->getMachineNode (Opcode, dl, MVT::i64 , getI32Imm (ImmHi16));
1225
- Result = CurDAG->getMachineNode (PPC::ORI8, dl, MVT::i64 , SDValue (Result, 0 ),
1226
- getI32Imm (Lo32 & 0xffff ));
1227
- // Use rldimi to insert the Low word into High word.
1228
- SDValue Ops[] = {SDValue (Result, 0 ), SDValue (Result, 0 ), getI32Imm (32 ),
1229
- getI32Imm (0 )};
1230
- return CurDAG->getMachineNode (PPC::RLDIMI, dl, MVT::i64 , Ops);
1231
- }
1232
- // 3-5) Patterns : {******}{33 zeros}{******}
1244
+ // 3-4) Patterns : {******}{33 zeros}{******}
1233
1245
// {******}{33 ones}{******}
1234
1246
// If the Imm contains 33 consecutive zeros/ones, it means that a total of 31
1235
1247
// bits remain on both sides. Rotate right the Imm to construct an int<32>
0 commit comments