File tree Expand file tree Collapse file tree 3 files changed +51
-1
lines changed Expand file tree Collapse file tree 3 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -6191,6 +6191,53 @@ G4_Imm::emitAutoFmt(std::ostream& output)
6191
6191
}
6192
6192
}
6193
6193
6194
+ int64_t G4_Imm::typecastVals (int64_t value, G4_Type type)
6195
+ {
6196
+ int64_t retVal = 0 ;
6197
+ switch (type)
6198
+ {
6199
+ case Type_UD:
6200
+ case Type_UV:
6201
+ case Type_VF:
6202
+ {
6203
+ retVal = (int64_t )((unsigned int )value);
6204
+ break ;
6205
+ }
6206
+ case Type_D:
6207
+ case Type_V:
6208
+ {
6209
+ retVal = (int64_t )((int )value);
6210
+ break ;
6211
+ }
6212
+ case Type_UW:
6213
+ {
6214
+ retVal = (int64_t )((uint16_t )value);
6215
+ break ;
6216
+ }
6217
+ case Type_W:
6218
+ {
6219
+ retVal = (int64_t )((int16_t )value);
6220
+ break ;
6221
+ }
6222
+ case Type_UB:
6223
+ {
6224
+ retVal = (int64_t )((uint8_t )value);
6225
+ break ;
6226
+ }
6227
+ case Type_B:
6228
+ {
6229
+ retVal = (int64_t )((int8_t )value);
6230
+ break ;
6231
+ }
6232
+ default :
6233
+ {
6234
+ // Dont do float conversions
6235
+ retVal = value;
6236
+ }
6237
+ }
6238
+ return retVal;
6239
+ }
6240
+
6194
6241
G4_RegVar *
6195
6242
G4_RegVarTransient::getNonTransientBaseRegVar ()
6196
6243
{
Original file line number Diff line number Diff line change @@ -2480,6 +2480,7 @@ class G4_Imm : public G4_Operand
2480
2480
2481
2481
static bool isInTypeRange (int64_t imm, G4_Type ty);
2482
2482
2483
+ static int64_t typecastVals (int64_t value, G4_Type type);
2483
2484
};
2484
2485
2485
2486
class G4_Reloc_Imm : public G4_Imm
Original file line number Diff line number Diff line change @@ -2950,7 +2950,9 @@ void Optimizer::newLocalCopyPropagation()
2950
2950
// replace use with def
2951
2951
if (src->isImm ())
2952
2952
{
2953
- G4_Imm* newImm = builder.createImm (src->asImm ()->getImm (),
2953
+ auto newImmVal = G4_Imm::typecastVals (src->asImm ()->getImm (),
2954
+ propType);
2955
+ G4_Imm* newImm = builder.createImm (newImmVal,
2954
2956
propType);
2955
2957
G4_SrcModifier modifier = use->asSrcRegRegion ()->getModifier ();
2956
2958
if (modifier != Mod_src_undef)
You can’t perform that action at this time.
0 commit comments