From 0a9df805f688d5eab8be380ab7c9dde115d88852 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 16 Sep 2016 17:55:58 -0700 Subject: br_if returns its value --- src/passes/RemoveUnusedBrs.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/passes/RemoveUnusedBrs.cpp') diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp index fa8ab2f6c..15482de25 100644 --- a/src/passes/RemoveUnusedBrs.cpp +++ b/src/passes/RemoveUnusedBrs.cpp @@ -146,11 +146,10 @@ struct RemoveUnusedBrs : public WalkerPass br_if (condition) Break* br = curr->ifTrue->dynCast(); if (br && !br->condition) { // TODO: if there is a condition, join them - // if the br has a value, then if => br_if means we always execute the value, and also the order is value,condition vs condition,value if (canTurnIfIntoBrIf(curr->condition, br->value)) { br->condition = curr->condition; br->finalize(); - replaceCurrent(br); + replaceCurrent(Builder(*getModule()).dropIfConcretelyTyped(br)); anotherCycle = true; } } @@ -407,18 +406,18 @@ struct RemoveUnusedBrs : public WalkerPassifTrue->dynCast(); if (ifTrueBreak && !ifTrueBreak->condition && canTurnIfIntoBrIf(iff->condition, ifTrueBreak->value)) { // we are an if-else where the ifTrue is a break without a condition, so we can do this - list[i] = ifTrueBreak; ifTrueBreak->condition = iff->condition; ifTrueBreak->finalize(); + list[i] = Builder(*getModule()).dropIfConcretelyTyped(ifTrueBreak); ExpressionManipulator::spliceIntoBlock(curr, i + 1, iff->ifFalse); continue; } // otherwise, perhaps we can flip the if auto* ifFalseBreak = iff->ifFalse->dynCast(); if (ifFalseBreak && !ifFalseBreak->condition && canTurnIfIntoBrIf(iff->condition, ifFalseBreak->value)) { - list[i] = ifFalseBreak; ifFalseBreak->condition = Builder(*getModule()).makeUnary(EqZInt32, iff->condition); ifFalseBreak->finalize(); + list[i] = Builder(*getModule()).dropIfConcretelyTyped(ifFalseBreak); ExpressionManipulator::spliceIntoBlock(curr, i + 1, iff->ifTrue); continue; } -- cgit v1.2.3