[Issue 4443] Optimizer produces wrong code for || or with struct arrays

2015-06-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=4443

Andrei Alexandrescu and...@erdani.com changed:

   What|Removed |Added

Version|D1  D2 |D2

--


[Issue 4443] Optimizer produces wrong code for || or with struct arrays

2010-08-05 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4443


Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||bugzi...@digitalmars.com
 Resolution||FIXED


--- Comment #5 from Walter Bright bugzi...@digitalmars.com 2010-08-05 
14:22:53 PDT ---
http://www.dsource.org/projects/dmd/changeset/601

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4443] Optimizer produces wrong code for || or with struct arrays

2010-08-04 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4443



--- Comment #4 from Don clugd...@yahoo.com.au 2010-08-04 00:07:00 PDT ---
(In reply to comment #3)
 if (!sregs)
 sregs = ALLREGS  ~rretregs;
 c3 = allocreg(sregs,reg,ty);
 }
 + // BUG: We should ensure there is only register in retregs
 reg1 = findreg(retregs);

That should be:

if (!sregs)
sregs = ALLREGS  ~rretregs;
c3 = allocreg(sregs,reg,ty);
}
+assert( (retregs  (retregs-1)) == 0); // Must be only one
register
reg1 = findreg(retregs);

There are probably contrived cases where this bug could occur in C++ code, but
I don't think it would ever occur in practice.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4443] Optimizer produces wrong code for || or with struct arrays

2010-08-03 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4443


Don clugd...@yahoo.com.au changed:

   What|Removed |Added

   Keywords||patch


--- Comment #3 from Don clugd...@yahoo.com.au 2010-08-03 21:56:32 PDT ---
This is a really subtle code generation bug. The buggy bit of code is below.
In this section of code, the expression size is one register. 
In the bit of code at L13, it checks to see if the addition factor is already
in a register.
In this case, it is, BUT it's actually in a double register: the {ptr, length}
pair is a ulong, and here it's been cast to uint to get the length.
So isregvar() returns BOTH registers in regm.
Then, at the end of this section of code, the register to use is selected with
a call to findreg(). But it just returns the first register which is correct
only if there is only one register.

In this patch, I just use the LSW returned from isregvar. It would also be
possible to change isregvar() to only return the LSW in the case where a cast
to smaller type has occured, but I don't know what other code expects from
isregvar. 

Not sure if the tysize() check is necessary. Maybe it could just be retregs = 1
 reg1;

PATCH: cod2.c, cdorth(), line 362. (Does 1reg1 work if reg1 is 0?).


L13:
regm_t regm;
if (e11-Eoper == OPvar  isregvar(e11,regm,reg1))
{
+if (tysize[tybasic(e11-Ety)]= REGSIZE)
+   retregs = 1  reg1; // Only want the LSW
+else
retregs = regm;
c1 = NULL;
freenode(e11);
}
else
c1 = codelem(e11,retregs,FALSE);
}
rretregs = ALLREGS  ~retregs;
c2 = scodelem(ebase,rretregs,retregs,TRUE);
{
regm_t sregs = *pretregs  ~rretregs;
if (!sregs)
sregs = ALLREGS  ~rretregs;
c3 = allocreg(sregs,reg,ty);
}
+ // BUG: We should ensure there is only register in retregs
reg1 = findreg(retregs);


Also noticed that in cod4.c, cdmsw() line 2838, there's an incorrect comment.
retregs = mMSW;// want LSW only
This should of course be // want MSW only

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---