|
|
Bugzilla Link |
20 |
Created on |
Jun 19, 2003 14:28 |
Resolution |
FIXED |
Resolved on |
Dec 01, 2003 19:09 |
Version |
1.00beta |
OS |
All |
Architecture |
All |
Attachments |
bug.sac |
Extended Description
The compiler backend generates wrong code the primitive operation reshape().
Example:
B = reshape( sv, A)
If the rc of A is 1 (A is the last reference of the array) B can reuse the data
vector of A. For the time being the following code is generated:
CHECK_REUSE( B, A)
ALLOC_BEGIN( B, ...)
PRF_RESHAPE__SHAPE( B, ...)
ALLOC_END( B, ...)
INC_RC( B)
IS_NOT_REUSED( B, A)
COPY_DATA( B, A)
The problem is about the CHECK_REUSE icm which is defined as follows:
if (RC(B) == 1)
ASSIGN( B, A)
else
/* allocation of B */
Unfortunately, ASSIGN is not correct here since A and B may have incompatible
descriptors! Instead, the following code should be generated:
if (RC(B) == 1)
ASSIGN_DESC( B, A)
ASSIGN_DATA( B, A)
PRF_RESHAPE__DIM( B, ...)
PRF_RESHAPE__SHAPE( B, ...)
else
ALLOC_BEGIN( B, ...)
PRF_RESHAPE__SHAPE( B, ...)
ALLOC_END( B, ...)
INC_RC( B)
IS_NOT_REUSED( B, A)
COPY_DATA( B, A)
or:
if (RC(B) == 1)
ASSIGN_DESC( B, A)
else
ALLOC_BEGIN( B, ...)
PRF_RESHAPE__SHAPE( B, ...)
ALLOC_END( B, ...)
INC_RC( B)
IS_REUSED( B, A)
PRF_RESHAPE__DIM( B, ...)
PRF_RESHAPE__SHAPE( B, ...)
ASSIGN_DATA( B, A)
ELSE
COPY_DATA( B, A)
A SAC program for reproducing the bug will be given as attachment.