From 5e813e6bd6b31bd2989c888d4eaf21ea0da1248d Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 14 Oct 2023 20:53:56 -0700 Subject: [PATCH] irjit: Correct bad Vec4 overlap handling. --- Core/MIPS/IR/IRPassSimplify.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/MIPS/IR/IRPassSimplify.cpp b/Core/MIPS/IR/IRPassSimplify.cpp index b98b03f44a..2d368d0191 100644 --- a/Core/MIPS/IR/IRPassSimplify.cpp +++ b/Core/MIPS/IR/IRPassSimplify.cpp @@ -2095,7 +2095,9 @@ bool ReduceVec4Flush(const IRWriter &in, IRWriter &out, const IROptions &opts) { if (overlapped(inst.dest, 1, inst.src1, 4, inst.src2, 4) && findAvailTempVec4()) { out.Write(inst.op, temp, inst.src1, inst.src2, inst.constant); if (usedLaterAsVec4(inst.dest & ~3)) { - out.Write(IROp::Vec4Shuffle, temp, inst.src1 & ~3, 0); + // Broadcast to other lanes if needed. + if ((inst.dest & 3) != 0) + out.Write(IROp::Vec4Shuffle, temp, temp, 0); out.Write(IROp::Vec4Blend, inst.dest & ~3, inst.dest & ~3, temp, 1 << (inst.dest & 3)); // It's overlapped, so it'll get marked as Vec4 and used anyway. isVec4Dirty[inst.dest & ~3] = true;