shader: Read branch conditions from an instruction
Fixes the identity removal pass.
This commit is contained in:
		| @@ -200,7 +200,7 @@ void Precolor(EmitContext& ctx, const IR::Program& program) { | ||||
|             } | ||||
|             // Add reference to the phi node on the phi predecessor to avoid overwritting it | ||||
|             for (size_t i = 0; i < num_args; ++i) { | ||||
|                 IR::IREmitter{*phi.PhiBlock(i)}.DummyReference(IR::Value{&phi}); | ||||
|                 IR::IREmitter{*phi.PhiBlock(i)}.Reference(IR::Value{&phi}); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -22,6 +22,10 @@ void EmitIdentity(EmitContext&, IR::Inst& inst, const IR::Value& value) { | ||||
|     Alias(inst, value); | ||||
| } | ||||
|  | ||||
| void EmitConditionRef(EmitContext&, IR::Inst& inst, const IR::Value& value) { | ||||
|     Alias(inst, value); | ||||
| } | ||||
|  | ||||
| void EmitBitCastU16F16(EmitContext&, IR::Inst& inst, const IR::Value& value) { | ||||
|     Alias(inst, value); | ||||
| } | ||||
|   | ||||
| @@ -22,7 +22,8 @@ class EmitContext; | ||||
| void EmitPhi(EmitContext& ctx, IR::Inst& inst); | ||||
| void EmitVoid(EmitContext& ctx); | ||||
| void EmitIdentity(EmitContext& ctx, IR::Inst& inst, const IR::Value& value); | ||||
| void EmitDummyReference(EmitContext&); | ||||
| void EmitConditionRef(EmitContext& ctx, IR::Inst& inst, const IR::Value& value); | ||||
| void EmitReference(EmitContext&); | ||||
| void EmitPhiMove(EmitContext& ctx, const IR::Value& phi, const IR::Value& value); | ||||
| void EmitJoin(EmitContext& ctx); | ||||
| void EmitDemoteToHelperInvocation(EmitContext& ctx); | ||||
|   | ||||
| @@ -21,7 +21,7 @@ void EmitPhi(EmitContext&, IR::Inst&) {} | ||||
|  | ||||
| void EmitVoid(EmitContext&) {} | ||||
|  | ||||
| void EmitDummyReference(EmitContext&) {} | ||||
| void EmitReference(EmitContext&) {} | ||||
|  | ||||
| void EmitPhiMove(EmitContext& ctx, const IR::Value& phi, const IR::Value& value) { | ||||
|     if (phi == value) { | ||||
|   | ||||
| @@ -139,6 +139,7 @@ void RegAlloc::Free(Id id) { | ||||
| /*static*/ bool RegAlloc::IsAliased(const IR::Inst& inst) { | ||||
|     switch (inst.GetOpcode()) { | ||||
|     case IR::Opcode::Identity: | ||||
|     case IR::Opcode::ConditionRef: | ||||
|     case IR::Opcode::BitCastU16F16: | ||||
|     case IR::Opcode::BitCastU32F32: | ||||
|     case IR::Opcode::BitCastU64F64: | ||||
|   | ||||
| @@ -469,7 +469,15 @@ Id EmitIdentity(EmitContext& ctx, const IR::Value& value) { | ||||
|     return id; | ||||
| } | ||||
|  | ||||
| void EmitDummyReference(EmitContext&) {} | ||||
| Id EmitConditionRef(EmitContext& ctx, const IR::Value& value) { | ||||
|     const Id id{ctx.Def(value)}; | ||||
|     if (!Sirit::ValidId(id)) { | ||||
|         throw NotImplementedException("Forward identity declaration"); | ||||
|     } | ||||
|     return id; | ||||
| } | ||||
|  | ||||
| void EmitReference(EmitContext&) {} | ||||
|  | ||||
| void EmitPhiMove(EmitContext&) { | ||||
|     throw LogicError("Unreachable instruction"); | ||||
|   | ||||
| @@ -23,7 +23,8 @@ class EmitContext; | ||||
| Id EmitPhi(EmitContext& ctx, IR::Inst* inst); | ||||
| void EmitVoid(EmitContext& ctx); | ||||
| Id EmitIdentity(EmitContext& ctx, const IR::Value& value); | ||||
| void EmitDummyReference(EmitContext&); | ||||
| Id EmitConditionRef(EmitContext& ctx, const IR::Value& value); | ||||
| void EmitReference(EmitContext&); | ||||
| void EmitPhiMove(EmitContext&); | ||||
| void EmitJoin(EmitContext& ctx); | ||||
| void EmitDemoteToHelperInvocation(EmitContext& ctx); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user