aboutsummaryrefslogtreecommitdiff
path: root/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp
diff options
context:
space:
mode:
authorFernandoS27 <fsahmkow27@gmail.com>2021-03-26 16:02:04 +0100
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-22 21:51:24 -0400
commit742d11c2ad948c8630be15901514ec9e5e5fcd20 (patch)
tree4d9e0976f8c95fbb5c8006b46579200315b04f0f /src/shader_recompiler/ir_opt/constant_propagation_pass.cpp
parent981eb6f43bb88f1e57b4c657bf37cb7471a113e3 (diff)
shader: Implement TLD4.PTP
Diffstat (limited to 'src/shader_recompiler/ir_opt/constant_propagation_pass.cpp')
-rw-r--r--src/shader_recompiler/ir_opt/constant_propagation_pass.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp b/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp
index 28060dccfa..12159e7386 100644
--- a/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp
+++ b/src/shader_recompiler/ir_opt/constant_propagation_pass.cpp
@@ -355,6 +355,17 @@ void FoldBranchConditional(IR::Inst& inst) {
}
}
+void FoldConstantComposite(IR::Inst& inst, size_t amount = 2) {
+ for (size_t i = 0; i < amount; i++) {
+ if (!inst.Arg(i).IsConstantContainer()) {
+ return;
+ }
+ }
+ auto info{inst.Flags<IR::CompositeDecoration>()};
+ info.is_constant = true;
+ inst.SetFlags(info);
+}
+
void ConstantPropagation(IR::Block& block, IR::Inst& inst) {
switch (inst.Opcode()) {
case IR::Opcode::GetRegister:
@@ -380,6 +391,13 @@ void ConstantPropagation(IR::Block& block, IR::Inst& inst) {
case IR::Opcode::SelectF32:
case IR::Opcode::SelectF64:
return FoldSelect(inst);
+ case IR::Opcode::CompositeConstructU32x2:
+ case IR::Opcode::CompositeConstructF16x2:
+ case IR::Opcode::CompositeConstructF32x2:
+ case IR::Opcode::CompositeConstructF64x2:
+ return FoldConstantComposite(inst, 2);
+ case IR::Opcode::CompositeConstructArrayU32x2:
+ return FoldConstantComposite(inst, 4);
case IR::Opcode::FPMul32:
return FoldFPMul32(inst);
case IR::Opcode::LogicalAnd: