Skip to content

Commit 1e1525b

Browse files
DinoVmeta-codesync[bot]
authored andcommitted
Promote comparisons to 32-bit outputs
Summary: Currently we fail to start cinder test runner on 3.12 because we hit an issue with a kEqual which is taking an 8-bit value. This comes from a previous kEqual which produces an 8-bit value. But we know that kEqual isn't going to produce an 8-bit value on ARM - it'll always produce a 32-bit value. So this changes it to promote it to a 32-bit value. An alternate take on this would be that we might want kEqual to not produce a bool or for the translation from a CBool to a size in LIR to be to 32-bits. Not producing a bool feels like it comes with a lot of risk. I don't think changing CBool to be 32-bits will work either because we do want it to be 8-bits when we're loading from memory. Reviewed By: kddnewton Differential Revision: D93541458 fbshipit-source-id: f208d064e41ce1ebb312ccbe6480f2f589a54e83
1 parent b329187 commit 1e1525b

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

cinderx/Jit/lir/postgen.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,34 @@ RewriteResult rewriteLoadSecondCallResult(instr_iter_t instr_iter) {
378378
return kRemoved;
379379
}
380380

381+
#if defined(CINDER_AARCH64)
382+
// On AArch64, we never are going to produce an output that is less than 32-bits
383+
// for our comparisons so promote all of these to 32-bits so we don't need to
384+
// mask them.
385+
RewriteResult rewritePromoteOutputSize(instr_iter_t instr_iter) {
386+
auto instr = instr_iter->get();
387+
switch (instr->opcode()) {
388+
case Instruction::kEqual:
389+
case Instruction::kNotEqual:
390+
case Instruction::kGreaterThanSigned:
391+
case Instruction::kGreaterThanEqualSigned:
392+
case Instruction::kLessThanSigned:
393+
case Instruction::kLessThanEqualSigned:
394+
case Instruction::kGreaterThanUnsigned:
395+
case Instruction::kGreaterThanEqualUnsigned:
396+
case Instruction::kLessThanUnsigned:
397+
case Instruction::kLessThanEqualUnsigned:
398+
if (instr->output()->sizeInBits() < 32) {
399+
instr->output()->setDataType(DataType::k32bit);
400+
return kChanged;
401+
}
402+
return kUnchanged;
403+
default:
404+
return kUnchanged;
405+
}
406+
}
407+
#endif
408+
381409
} // namespace
382410

383411
void PostGenerationRewrite::registerRewrites() {
@@ -391,6 +419,8 @@ void PostGenerationRewrite::registerRewrites() {
391419

392420
#if defined(CINDER_X86_64)
393421
registerOneRewriteFunction(rewriteMoveToMemoryLargeConstant, 1);
422+
#elif defined(CINDER_AARCH64)
423+
registerOneRewriteFunction(rewritePromoteOutputSize, 1);
394424
#endif
395425

396426
registerOneRewriteFunction(rewriteLoadSecondCallResult, 1);

0 commit comments

Comments
 (0)