Author: zhuqing
Date: 2011-07-26 04:20:18 -0400 (Tue, 26 Jul 2011)
New Revision: 3701
Modified:
trunk/osprey/be/cg/x8664/ebo_special.cxx
Log:
Fix EBO mul problem:
When compiling a function like:
long fooBig(long x) {
return (x * (((long)1) << 63));
}
EBO will try to optimize this mul operation, in the function Convert_Imm_Mul.
At the beginning of this function, the statement
INT64 val = imm_val < 0 ? -imm_val : imm_val;
is trying to get the absolute value of imm_val, but in this case, imm_val is
((long)1) << 63, which makes .imm_val is the same as imm_val. Then, in the loop
int power = 0;
while( val != 1 ){
power++;
val >>= 1;
}
val will keep being -1, which make this loop endless.
The solution is to change the type of imm_val from INT64 to UINT64.
Approved by Sun Chan.
Modified: trunk/osprey/be/cg/x8664/ebo_special.cxx
===================================================================
--- trunk/osprey/be/cg/x8664/ebo_special.cxx 2011-07-22 20:08:40 UTC (rev
3700)
+++ trunk/osprey/be/cg/x8664/ebo_special.cxx 2011-07-26 08:20:18 UTC (rev
3701)
@@ -1814,7 +1814,7 @@
OP *new_op = NULL;
const BOOL is_64bit = (TN_size(tnr) == 8);
const TYPE_ID mtype = is_64bit ? MTYPE_I8 : MTYPE_I4;
- INT64 val = imm_val < 0 ? -imm_val : imm_val;
+ UINT64 val = imm_val < 0 ? -imm_val : imm_val;
OPS ops = OPS_EMPTY;
if( imm_val == 0 ){
@@ -1840,6 +1840,8 @@
bool need_an_add = false;
+ /* Check for an unsigned power of two + 1. */
+
if( val >= 2 &&
( (val-1) & (val-2) ) == 0 ){
val--;
@@ -1847,7 +1849,7 @@
}
/* Check whether it can carry an imm opnd. */
-
+ /* Check for unsigned power of two. */
if( ( val & ( val - 1 ) ) != 0 ){
const TOP new_top = TOP_with_Imm_Opnd( op, 1, imm_val );
@@ -1871,6 +1873,8 @@
tn = tmp;
}
+ /* determine the power of val. */
+
int power = 0;
while( val != 1 ){
power++;
@@ -1883,7 +1887,7 @@
Expand_Add( tnr, tnr, tn, mtype, &ops );
}
- if( imm_val < 0 )
+ if( imm_val < 0 && imm_val != INT64_MIN )
Expand_Neg( tnr, tnr, mtype, &ops );
BB_Insert_Ops_After( OP_bb(op), op, &ops );
------------------------------------------------------------------------------
Magic Quadrant for Content-Aware Data Loss Prevention
Research study explores the data loss prevention market. Includes in-depth
analysis on the changes within the DLP market, and the criteria used to
evaluate the strengths and weaknesses of these DLP solutions.
http://www.accelacomm.com/jaw/sfnl/114/51385063/
_______________________________________________
Open64-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/open64-devel