From 32a6dfe3b0089452e0684cf9555bbd9322d6fdff Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Thu, 19 Dec 2024 19:37:52 -0800 Subject: [PATCH] rewrite non-POD copies (#20581) --- compiler/src/dmd/backend/cgelem.d | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/compiler/src/dmd/backend/cgelem.d b/compiler/src/dmd/backend/cgelem.d index f63a4635131..6396d5d573f 100644 --- a/compiler/src/dmd/backend/cgelem.d +++ b/compiler/src/dmd/backend/cgelem.d @@ -3706,6 +3706,20 @@ elem * elstruct(elem *e, Goal goal) default: Ldefault: { + if (e.Eoper == OPstreq && tym < TYMAX && e.E1.Eoper == OPvar && e.E2.Eoper == OPvar && e.ET) + { + /* change (e1 streq e2) to ((e1 = e2), e1) + * A bit restrictive to only allow OPvar + */ + elem* en = el_bin(OPcomma, e.ET.Tty, e, el_copytree(e.E1)); + en.ET = e.ET; + e.Eoper = OPeq; + e.Ety = tym; + e.E1.Ety = tym; + e.E2.Ety = tym; + e = en; + break; + } elem **pe2; if (e.Eoper == OPstreq) pe2 = &e.E2;