Author: pallavimathew
Date: 2011-05-13 15:16:30 -0400 (Fri, 13 May 2011)
New Revision: 3599

Modified:
   trunk/osprey/wgen/wgen_expr.cxx
Log:

Here are testcases that produce failing result when compiled with opencc.
------------------------------
#include <stdio.h>
char myfunc(char i)
{
        return i*2;
}

int main()
{
          int i=0x40;
          printf("size of char %d\n", sizeof(char));
          if(myfunc(i) != (char)(i*2.0))
           printf("Failed\n");
          else
           printf("Passed\n");
        return 0;
}

------------------------------

#include <stdio.h>
int main()
{
          int i=0x40;
          if((char)0x80 != (char)(i*2.0))
           printf("Failed\n");
          else
           printf("Passed\n");
        return 0;
}

------------------------------
The following test from the GCC 4.2 regression suite:
.../testsuite/gcc.dg/sync-2.c


Problem/Fix Description:

  The problem is that the types of the sub-exressions (operands) of a gspin
  GS_NE_EXPR operator are not converted correctly during the translation to
  a WHIRL I4I4NE expression.  The types of the GS_NE_EXPR operands are both
  "char" and the translation produces WHIRL sub-expressions of type "int".
  The fix is to check the types of the gspin comparison node's sub-expressions
  and add conversions as necessary.

Code review by Jian-Xin Lai.


Modified: trunk/osprey/wgen/wgen_expr.cxx
===================================================================
--- trunk/osprey/wgen/wgen_expr.cxx     2011-05-13 18:57:32 UTC (rev 3598)
+++ trunk/osprey/wgen/wgen_expr.cxx     2011-05-13 19:16:30 UTC (rev 3599)
@@ -7191,6 +7191,16 @@
         wn1 = WN_CreateCvtl(OPR_CVTL, Widen_Mtype(mtyp1), MTYPE_V,
                             MTYPE_size_min(mtyp1), wn1);
 
+       if (MTYPE_is_integral(mtyp) && MTYPE_is_integral(mtyp0) &&
+           MTYPE_size_min(mtyp) > MTYPE_size_min(mtyp0) )
+         wn0 = WN_CreateCvtl(OPR_CVTL, Widen_Mtype(mtyp0), MTYPE_V,
+                             MTYPE_size_min(mtyp0), wn0);
+
+       if (MTYPE_is_integral(mtyp) && MTYPE_is_integral(mtyp1) &&
+           MTYPE_size_min(mtyp) > MTYPE_size_min(mtyp1) )
+         wn1 = WN_CreateCvtl(OPR_CVTL, Widen_Mtype(mtyp1), MTYPE_V,
+                             MTYPE_size_min(mtyp1), wn1);
+
 #ifdef TARG_IA64
        wn  = WN_Relational (Operator_From_Tree [code].opr,
                            Widen_Mtype(mtyp0), wn0, wn1);


------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to