From: Florian Krohm Date: Thu, 25 Jun 2026 22:22:20 +0000 (+0000) Subject: s390: Remove Put(...) = Get(...) when the offsets are identical. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3a62e417c6f11ed869edb3fb5cb64b93d06b76b2;p=thirdparty%2Fvalgrind.git s390: Remove Put(...) = Get(...) when the offsets are identical. Interestingly this pattern is observed. Not sure whether it's worthwhile to add a peephole optimisation pass after tree building. VexTranslateArgs::finaltidy looks like a candidate but it appears to be indended for tools. --- diff --git a/VEX/priv/host_s390_isel.c b/VEX/priv/host_s390_isel.c index abf026eb1..c29e9d786 100644 --- a/VEX/priv/host_s390_isel.c +++ b/VEX/priv/host_s390_isel.c @@ -5075,6 +5075,12 @@ s390_isel_stmt(ISelEnv *env, IRStmt *stmt) s390_amode *am; ULong new_value, old_value, difference; + /* Peephole optimization: PUT(...) = GET:I64(...) can be thrown out + iff guest state offsets are identical. */ + if (stmt->Ist.Put.data->tag == Iex_Get && + stmt->Ist.Put.data->Iex.Get.offset == stmt->Ist.Put.offset) + return; + /* Detect updates to certain guest registers. We track the contents of those registers as long as they contain constants. If the new constant is either zero or in the 8-bit neighbourhood of the