@@ -2332,7 +2332,6 @@ IRBuilderAsmJs::BuildInt2(Js::OpCodeAsmJs newOpcode, uint32 offset, Js::RegSlot
2332
2332
dstOpnd->SetValueType (ValueType::GetInt (false ));
2333
2333
2334
2334
IR::Instr * instr = nullptr ;
2335
- IRType signExtendFromType = TyIllegal;
2336
2335
switch (newOpcode)
2337
2336
{
2338
2337
case Js::OpCodeAsmJs::BeginSwitch_Int:
@@ -2396,11 +2395,11 @@ IRBuilderAsmJs::BuildInt2(Js::OpCodeAsmJs newOpcode, uint32 offset, Js::RegSlot
2396
2395
instr = IR::Instr::New (Js::OpCode::GrowWasmMemory, dstOpnd, BuildSrcOpnd (AsmJsRegSlots::WasmMemoryReg, TyVar), srcOpnd, m_func);
2397
2396
break ;
2398
2397
2399
- case Js::OpCodeAsmJs::I32Extend8_s: signExtendFromType = TyInt8; goto make_sign_extend;
2400
- case Js::OpCodeAsmJs::I32Extend16_s: signExtendFromType = TyInt16; goto make_sign_extend ;
2401
- make_sign_extend:
2402
- // Src2 is a dummy source, used only to carry the type to cast from
2403
- instr = IR::Instr::New (Js::OpCode::Conv_Prim, dstOpnd, srcOpnd, IR::IntConstOpnd::New (signExtendFromType, signExtendFromType, m_func), m_func );
2398
+ case Js::OpCodeAsmJs::I32Extend8_s:
2399
+ instr = CreateSignExtendInstr (dstOpnd, srcOpnd, TyInt8) ;
2400
+ break ;
2401
+ case Js::OpCodeAsmJs::I32Extend16_s:
2402
+ instr = CreateSignExtendInstr ( dstOpnd, srcOpnd, TyInt16 );
2404
2403
break ;
2405
2404
default :
2406
2405
Assume (UNREACHED);
@@ -2430,6 +2429,15 @@ IR::RegOpnd* IRBuilderAsmJs::BuildTrapIfMinIntOverNegOne(IR::RegOpnd* src1Opnd,
2430
2429
return newSrc;
2431
2430
}
2432
2431
2432
+ IR::Instr* IRBuilderAsmJs::CreateSignExtendInstr (IR::Opnd* dst, IR::Opnd* src, IRType fromType)
2433
+ {
2434
+ // Since CSE ignores the type of the type, the int const value carries that information to prevent
2435
+ // cse of sign extension of different types.
2436
+ IR::Opnd* fromTypeOpnd = IR::IntConstOpnd::New (fromType, fromType, m_func);
2437
+ // Src2 is a dummy source, used only to carry the type to cast from
2438
+ return IR::Instr::New (Js::OpCode::Conv_Prim, dst, src, fromTypeOpnd, m_func);
2439
+ }
2440
+
2433
2441
void
2434
2442
IRBuilderAsmJs::BuildInt3 (Js::OpCodeAsmJs newOpcode, uint32 offset, Js::RegSlot dstRegSlot, Js::RegSlot src1RegSlot, Js::RegSlot src2RegSlot)
2435
2443
{
@@ -3028,7 +3036,6 @@ IRBuilderAsmJs::BuildLong2(Js::OpCodeAsmJs newOpcode, uint32 offset, Js::RegSlot
3028
3036
dstOpnd->SetValueType (ValueType::GetInt (false ));
3029
3037
3030
3038
IR::Instr * instr = nullptr ;
3031
- IRType signExtendFromType = TyIllegal;
3032
3039
switch (newOpcode)
3033
3040
{
3034
3041
case Js::OpCodeAsmJs::Ld_Long:
@@ -3055,12 +3062,14 @@ IRBuilderAsmJs::BuildLong2(Js::OpCodeAsmJs newOpcode, uint32 offset, Js::RegSlot
3055
3062
AddInstr (slotInstr, offset);
3056
3063
}
3057
3064
break ;
3058
- case Js::OpCodeAsmJs::I64Extend8_s: signExtendFromType = TyInt8; goto make_sign_extend;
3059
- case Js::OpCodeAsmJs::I64Extend16_s: signExtendFromType = TyInt16; goto make_sign_extend;
3060
- case Js::OpCodeAsmJs::I64Extend32_s: signExtendFromType = TyInt32;
3061
- make_sign_extend:
3062
- // Src2 is a dummy source, used only to carry the type to cast from
3063
- instr = IR::Instr::New (Js::OpCode::Conv_Prim, dstOpnd, srcOpnd, IR::IntConstOpnd::New (signExtendFromType, signExtendFromType, m_func), m_func);
3065
+ case Js::OpCodeAsmJs::I64Extend8_s:
3066
+ instr = CreateSignExtendInstr (dstOpnd, srcOpnd, TyInt8);
3067
+ break ;
3068
+ case Js::OpCodeAsmJs::I64Extend16_s:
3069
+ instr = CreateSignExtendInstr (dstOpnd, srcOpnd, TyInt16);
3070
+ break ;
3071
+ case Js::OpCodeAsmJs::I64Extend32_s:
3072
+ instr = CreateSignExtendInstr (dstOpnd, srcOpnd, TyInt32);
3064
3073
break ;
3065
3074
default :
3066
3075
Assume (UNREACHED);
0 commit comments