mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 06:08:30 +09:00
[Fix] (MG_Util/ShaderTranspiler): fix bug FloatEqualsZeroEliminationPass where it may skip one instruction
This commit is contained in:
@@ -39,7 +39,7 @@ namespace MobileGL {
|
|||||||
// 3. iterate all function -> basic block -> insn
|
// 3. iterate all function -> basic block -> insn
|
||||||
for (auto& func : *get_module()) {
|
for (auto& func : *get_module()) {
|
||||||
for (auto& bb : func) {
|
for (auto& bb : func) {
|
||||||
for (auto itInst = bb.begin(); itInst != bb.end(); ++itInst) {
|
for (auto itInst = bb.begin(); itInst != bb.end(); ) {
|
||||||
auto& inst = *itInst;
|
auto& inst = *itInst;
|
||||||
|
|
||||||
bool shouldSkip = true;
|
bool shouldSkip = true;
|
||||||
@@ -58,8 +58,10 @@ namespace MobileGL {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldSkip)
|
if (shouldSkip) {
|
||||||
|
++itInst;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// check if operand is "float 0.0"
|
// check if operand is "float 0.0"
|
||||||
// OpFOrdEqual ResultType ResultID Operand1 Operand2
|
// OpFOrdEqual ResultType ResultID Operand1 Operand2
|
||||||
@@ -81,6 +83,7 @@ namespace MobileGL {
|
|||||||
} else if (is_float_zero(op1_id)) {
|
} else if (is_float_zero(op1_id)) {
|
||||||
var_id = op2_id; // 0.0 == x
|
var_id = op2_id; // 0.0 == x
|
||||||
} else {
|
} else {
|
||||||
|
++itInst;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,6 +146,8 @@ namespace MobileGL {
|
|||||||
auto nextInstIt = context()->KillInst(&inst);
|
auto nextInstIt = context()->KillInst(&inst);
|
||||||
if (nextInstIt) {
|
if (nextInstIt) {
|
||||||
itInst = nextInstIt;
|
itInst = nextInstIt;
|
||||||
|
} else {
|
||||||
|
++itInst;
|
||||||
}
|
}
|
||||||
|
|
||||||
modified = true;
|
modified = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user