[JIT] Fix constant propagation for OPCODE_SELECT.
This commit is contained in:
parent
94284ea9aa
commit
4c04a9383a
|
@ -278,11 +278,13 @@ bool ConstantPropagationPass::Run(HIRBuilder* builder) {
|
|||
if (i->src1.value->IsConstant()) {
|
||||
if (i->src1.value->type != VEC128_TYPE) {
|
||||
if (i->src1.value->IsConstantTrue()) {
|
||||
v->set_from(i->src2.value);
|
||||
i->Remove();
|
||||
auto src2 = i->src2.value;
|
||||
i->Replace(&OPCODE_ASSIGN_info, 0);
|
||||
i->set_src1(src2);
|
||||
} else if (i->src1.value->IsConstantFalse()) {
|
||||
v->set_from(i->src3.value);
|
||||
i->Remove();
|
||||
auto src3 = i->src3.value;
|
||||
i->Replace(&OPCODE_ASSIGN_info, 0);
|
||||
i->set_src1(src3);
|
||||
} else if (i->src2.value->IsConstant() &&
|
||||
i->src3.value->IsConstant()) {
|
||||
// TODO: Select
|
||||
|
|
|
@ -53,10 +53,15 @@ PPCTranslator::PPCTranslator(PPCFrontend* frontend) : frontend_(frontend) {
|
|||
if (validate) compiler_->AddPass(std::make_unique<passes::ValidationPass>());
|
||||
compiler_->AddPass(std::make_unique<passes::ContextPromotionPass>());
|
||||
if (validate) compiler_->AddPass(std::make_unique<passes::ValidationPass>());
|
||||
compiler_->AddPass(std::make_unique<passes::SimplificationPass>());
|
||||
if (validate) compiler_->AddPass(std::make_unique<passes::ValidationPass>());
|
||||
compiler_->AddPass(std::make_unique<passes::ConstantPropagationPass>());
|
||||
if (validate) compiler_->AddPass(std::make_unique<passes::ValidationPass>());
|
||||
// TODO(gibbed): loop until these passes stop making changes?
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
compiler_->AddPass(std::make_unique<passes::SimplificationPass>());
|
||||
if (validate)
|
||||
compiler_->AddPass(std::make_unique<passes::ValidationPass>());
|
||||
compiler_->AddPass(std::make_unique<passes::ConstantPropagationPass>());
|
||||
if (validate)
|
||||
compiler_->AddPass(std::make_unique<passes::ValidationPass>());
|
||||
}
|
||||
if (backend->machine_info()->supports_extended_load_store) {
|
||||
// Backend supports the advanced LOAD/STORE instructions.
|
||||
// These will save us a lot of HIR opcodes.
|
||||
|
|
|
@ -159,3 +159,44 @@ test_slw_9_constant:
|
|||
#_ REGISTER_OUT r3 0
|
||||
#_ REGISTER_OUT r4 0xFFFFFFFFFFFFFFFF
|
||||
#_ REGISTER_OUT r5 32
|
||||
|
||||
test_slw_10:
|
||||
#_ REGISTER_IN r4 99
|
||||
#_ REGISTER_IN r5 1
|
||||
cntlzw r5, r5
|
||||
subi r5, r5, 28
|
||||
slw r3, r4, r5
|
||||
blr
|
||||
#_ REGISTER_OUT r3 792
|
||||
#_ REGISTER_OUT r4 99
|
||||
#_ REGISTER_OUT r5 3
|
||||
|
||||
test_slw_10_constant:
|
||||
#_ REGISTER_IN r4 99
|
||||
li r5, 1
|
||||
cntlzw r5, r5
|
||||
subi r5, r5, 28
|
||||
slw r3, r4, r5
|
||||
blr
|
||||
#_ REGISTER_OUT r3 792
|
||||
#_ REGISTER_OUT r4 99
|
||||
#_ REGISTER_OUT r5 3
|
||||
|
||||
test_slw_11:
|
||||
#_ REGISTER_IN r4 99
|
||||
#_ REGISTER_IN r5 3
|
||||
li r5, 3
|
||||
slw r3, r4, r5
|
||||
blr
|
||||
#_ REGISTER_OUT r3 792
|
||||
#_ REGISTER_OUT r4 99
|
||||
#_ REGISTER_OUT r5 3
|
||||
|
||||
test_slw_11_constant:
|
||||
#_ REGISTER_IN r4 99
|
||||
li r5, 3
|
||||
slw r3, r4, r5
|
||||
blr
|
||||
#_ REGISTER_OUT r3 792
|
||||
#_ REGISTER_OUT r4 99
|
||||
#_ REGISTER_OUT r5 3
|
||||
|
|
Loading…
Reference in New Issue