@@ -397,13 +397,13 @@ IR::Instr* LowererMD::Simd128LoadConst(IR::Instr* instr)
397397 return instr->m_prev ;
398398}
399399
400- IR::Instr* LowererMD::Simd128CanonicalizeToBools (IR::Instr* instr, const Js::OpCode &CMPopCode , IR::Opnd& dstOpnd)
400+ IR::Instr* LowererMD::Simd128CanonicalizeToBools (IR::Instr* instr, const Js::OpCode &cmpOpcode , IR::Opnd& dstOpnd)
401401{
402402 Assert (instr->m_opcode == Js::OpCode::Simd128_IntsToB4 || instr->m_opcode == Js::OpCode::Simd128_IntsToB8 || instr->m_opcode == Js::OpCode::Simd128_IntsToB16 ||
403403 instr->m_opcode == Js::OpCode::Simd128_ReplaceLane_B4 || instr->m_opcode == Js::OpCode::Simd128_ReplaceLane_B8 || instr->m_opcode == Js::OpCode::Simd128_ReplaceLane_B16);
404404 IR::Instr *pInstr;
405- // dst = SIMDCMPOpCode dst, X86_ALL_ZEROS
406- pInstr = IR::Instr::New (CMPopCode , &dstOpnd, &dstOpnd, IR::MemRefOpnd::New ((void *)&X86_ALL_ZEROS, TySimd128I4, m_func), m_func);
405+ // dst = cmpOpcode dst, X86_ALL_ZEROS
406+ pInstr = IR::Instr::New (cmpOpcode , &dstOpnd, &dstOpnd, IR::MemRefOpnd::New ((void *)&X86_ALL_ZEROS, TySimd128I4, m_func), m_func);
407407 instr->InsertBefore (pInstr);
408408 Legalize (pInstr);
409409 // dst = PANDN dst, X86_ALL_NEG_ONES
@@ -741,16 +741,10 @@ IR::Instr* LowererMD::Simd128LowerLdLane(IR::Instr *instr)
741741 {
742742 if (laneType == TyInt8)
743743 {
744- // move value to byte-addressable reg
745- IR::RegOpnd * ebxOpnd = IR::RegOpnd::New (TyInt32, m_func);
746- #ifdef _M_IX86
747- ebxOpnd->SetReg (RegEBX);
748- #else
749- ebxOpnd->SetReg (RegRBX);
750- #endif
751- newInstr = IR::Instr::New (Js::OpCode::MOV, ebxOpnd, dst, m_func);
744+ IR::RegOpnd * tmp = IR::RegOpnd::New (TyInt8, m_func);
745+ newInstr = IR::Instr::New (Js::OpCode::MOV, tmp, dst, m_func);
752746 instr->InsertBefore (newInstr);
753- newInstr = IR::Instr::New (Js::OpCode::MOVSX, dst, ebxOpnd-> UseWithNewType (laneType, m_func) , m_func);
747+ newInstr = IR::Instr::New (Js::OpCode::MOVSX, dst, tmp , m_func);
754748 }
755749 else
756750 {
@@ -770,7 +764,7 @@ IR::Instr* LowererMD::Simd128LowerLdLane(IR::Instr *instr)
770764 instr->m_opcode == Js::OpCode::Simd128_ExtractLane_B16)
771765 {
772766 IR::Instr* pInstr = nullptr ;
773- IR::RegOpnd* ebxOpnd = IR::RegOpnd::New (TyInt32 , m_func);
767+ IR::RegOpnd* tmp = IR::RegOpnd::New (TyInt8 , m_func);
774768
775769 // cmp dst, -1
776770 pInstr = IR::Instr::New (Js::OpCode::CMP, m_func);
@@ -779,19 +773,16 @@ IR::Instr* LowererMD::Simd128LowerLdLane(IR::Instr *instr)
779773 instr->InsertBefore (pInstr);
780774 Legalize (pInstr);
781775
782- // Need an EBX register for byte addressing.
783- // movd ebx, dst
784- // type cast ebx to Int8.
785- instr->InsertBefore (IR::Instr::New (Js::OpCode::MOV, ebxOpnd, dst, m_func));
786- IR::Opnd *dst_i8 = ebxOpnd->UseWithNewType (TyInt8, this ->m_func );
776+ // mov tmp(TyInt8), dst
777+ instr->InsertBefore (IR::Instr::New (Js::OpCode::MOV, tmp, dst, m_func));
787778
788- // sete dst_i8, al
789- pInstr = IR::Instr::New (Js::OpCode::SETE, dst_i8, dst_i8 , m_func);
779+ // sete tmp(TyInt8)
780+ pInstr = IR::Instr::New (Js::OpCode::SETE, tmp, tmp , m_func);
790781 instr->InsertBefore (pInstr);
791782 Legalize (pInstr);
792783
793- // mov dst, dst_i8
794- instr->InsertBefore (IR::Instr::New (Js::OpCode::MOV , dst, dst_i8 , m_func));
784+ // movsx dst, tmp(TyInt8)
785+ instr->InsertBefore (IR::Instr::New (Js::OpCode::MOVSX , dst, tmp , m_func));
795786 }
796787
797788 IR::Instr* prevInstr = instr->m_prev ;
@@ -1343,7 +1334,7 @@ IR::Instr* LowererMD::Simd128LowerShift(IR::Instr *instr)
13431334 {
13441335 IR::RegOpnd * shamtReg = IR::RegOpnd::New (TyInt8, m_func);
13451336 shamtReg->SetReg (LowererMDArch::GetRegShiftCount ());
1346- IR::RegOpnd * ebxOpnd = IR::RegOpnd::New (TyInt32 , m_func);
1337+ IR::RegOpnd * tmp = IR::RegOpnd::New (TyInt8 , m_func);
13471338
13481339 // MOVAPS dst, src1
13491340 instr->InsertBefore (IR::Instr::New (Js::OpCode::MOVAPS, dst, src1, m_func));
@@ -1355,17 +1346,12 @@ IR::Instr* LowererMD::Simd128LowerShift(IR::Instr *instr)
13551346 instr->InsertBefore (IR::Instr::New (Js::OpCode::SHR, reg2, reg2, shamtReg, m_func));
13561347
13571348
1358- // MOV ebx, reg2
1359- // MOVSX reg2, bl (lower 8 bit)
1360- // make sure reg2 can be in a byte reg
1361- #ifdef _M_IX86
1362- reg2->SetReg (RegEBX);
1363- #else
1364- reg2->SetReg (RegRBX);
1365- #endif
1366- instr->InsertBefore (IR::Instr::New (Js::OpCode::MOV, ebxOpnd, reg2, m_func));
1349+ // MOV tmp(TyInt8), reg2
1350+ // MOVSX reg2, tmp(TyInt8)
13671351
1368- instr->InsertBefore (IR::Instr::New (Js::OpCode::MOVSX, reg2, ebxOpnd->UseWithNewType (TyInt8, m_func), m_func));
1352+ instr->InsertBefore (IR::Instr::New (Js::OpCode::MOV, tmp, reg2, m_func));
1353+
1354+ instr->InsertBefore (IR::Instr::New (Js::OpCode::MOVSX, reg2, tmp, m_func));
13691355 IR::RegOpnd *mask = IR::RegOpnd::New (TySimd128I4, m_func);
13701356 // PSRLW dst, mask
13711357 instr->InsertBefore (IR::Instr::New (Js::OpCode::PSRLW, dst, dst, tmp0, m_func));
@@ -2463,50 +2449,36 @@ IR::Instr* LowererMD::Simd128LowerAllTrue(IR::Instr* instr)
24632449 IR::Instr *pInstr;
24642450 IR::Opnd* dst = instr->GetDst ();
24652451 IR::Opnd* src1 = instr->GetSrc1 ();
2452+
24662453 Assert (dst->IsRegOpnd () && dst->IsInt32 ());
24672454 Assert (src1->IsRegOpnd () && src1->IsSimd128 ());
2468- // mov dst, 0
2469- // pmovmskb reg, src1
2470- // cmp reg, 0FFFFh
2471- // sete dst, (al)
2472-
2473- IR::RegOpnd *reg = IR::RegOpnd::New (TyInt32, this ->m_func );
2474- IR::RegOpnd *ebxOpnd = IR::RegOpnd::New (TyInt32, m_func);
2475-
2476- // mov dst, 0
2477- pInstr = IR::Instr::New (Js::OpCode::MOV, dst, IR::IntConstOpnd::New (0 , TyInt32, m_func), m_func);
2478- instr->InsertBefore (pInstr);
2479- Legalize (pInstr);
2455+
2456+ IR::Opnd * tmp = IR::RegOpnd::New (TyInt8, m_func);
24802457
2481- // pmovmskb reg , src1
2482- pInstr = IR::Instr::New (Js::OpCode::PMOVMSKB, reg , src1, m_func);
2458+ // pmovmskb dst , src1
2459+ pInstr = IR::Instr::New (Js::OpCode::PMOVMSKB, dst , src1, m_func);
24832460 instr->InsertBefore (pInstr);
24842461
2485- // cmp reg , 0FFFFh
2462+ // cmp dst , 0FFFFh
24862463 pInstr = IR::Instr::New (Js::OpCode::CMP, m_func);
2487- pInstr->SetSrc1 (reg );
2488- pInstr->SetSrc2 (IR::IntConstOpnd::New (0xFFFF , TyInt32, m_func, true ));
2464+ pInstr->SetSrc1 (dst );
2465+ pInstr->SetSrc2 (IR::IntConstOpnd::New (0x0FFFF , TyInt32, m_func, true ));
24892466 instr->InsertBefore (pInstr);
24902467 Legalize (pInstr);
24912468
2492- // mov ebx, dst
2493- // Need an EBX register to be byte addressable.
2494- instr->InsertBefore (IR::Instr::New (Js::OpCode::MOV, ebxOpnd, dst, m_func));
2495- IR::Opnd *dst_i8 = ebxOpnd->UseWithNewType (TyInt8, this ->m_func );
2469+ // mov tmp(TyInt8), dst
2470+ instr->InsertBefore (IR::Instr::New (Js::OpCode::MOV, tmp, dst, m_func));
24962471
2497- // sete dst, al
2498- pInstr = IR::Instr::New (Js::OpCode::SETE, dst_i8, dst_i8 , m_func);
2472+ // sete tmp(TyInt8)
2473+ pInstr = IR::Instr::New (Js::OpCode::SETE, tmp, tmp , m_func);
24992474 instr->InsertBefore (pInstr);
25002475 Legalize (pInstr);
25012476
2502- // mov dst_i8, dst
2503- instr->InsertBefore (IR::Instr::New (Js::OpCode::MOV, dst, dst_i8, m_func));
2504-
2477+ // movsx dst, dst(TyInt8)
2478+ instr->InsertBefore (IR::Instr::New (Js::OpCode::MOVSX, dst, tmp, m_func));
25052479
25062480 pInstr = instr->m_prev ;
25072481 instr->Remove ();
2508-
2509-
25102482 return pInstr;
25112483}
25122484
@@ -3085,7 +3057,6 @@ LowererMD::Simd128LoadHeadSegment(IR::IndirOpnd *indirOpnd, ValueType arrType, I
30853057 }
30863058 else
30873059 {
3088- // REVIEW: Is this needed ? Shouldn't globOpt make sure headSegSym is set and alive ?
30893060 // MOV headSegment, [base + offset(head)]
30903061 int32 headOffset = m_lowerer->GetArrayOffsetOfHeadSegment (arrType);
30913062 IR::IndirOpnd * indirOpnd = IR::IndirOpnd::New (arrayRegOpnd, headOffset, TyMachPtr, this ->m_func );
@@ -3476,8 +3447,6 @@ void LowererMD::InsertShufps(uint8 lanes[], IR::Opnd *dst, IR::Opnd *src1, IR::O
34763447 }
34773448 else if (dst->IsEqual (src2))
34783449 {
3479- // REVIEW: Could this be a problem with RegAlloc ? If the regAlloc decides to assign two regs for dst in
3480- // the two definitions, we will have incorrect code.
34813450
34823451 // MOVAPS tmp, dst
34833452 instr->InsertBefore (IR::Instr::New (Js::OpCode::MOVAPS, tmp, dst, m_func));
@@ -3488,9 +3457,6 @@ void LowererMD::InsertShufps(uint8 lanes[], IR::Opnd *dst, IR::Opnd *src1, IR::O
34883457 }
34893458 else
34903459 {
3491- // REVIEW: Could this be a problem with RegAlloc ? If the regAlloc decides to assign two regs for dst in
3492- // the two definitions, we will have incorrect code.
3493-
34943460 // MOVAPS dst, src1
34953461 instr->InsertBefore (IR::Instr::New (Js::OpCode::MOVAPS, dst, src1, m_func));
34963462 // SHUF dst, src2, imm8
0 commit comments