coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: issues with new factor on sparc


From: Pádraig Brady
Subject: Re: issues with new factor on sparc
Date: Tue, 23 Oct 2012 01:37:41 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1

On 10/22/2012 02:21 PM, Pádraig Brady wrote:
compile warning with gcc 3.4.3 on
SunOS login 5.10 Generic_147440-19 sun4v sparc SUNW,SPARC-Enterprise-T5220
  src/factor.c: In function `factor_using_pollard_rho2':
  src/factor.c:1535: warning: right shift count >= width of type
  src/factor.c:1558: warning: right shift count >= width of type
  src/factor.c:1568: warning: right shift count >= width of type

compile failure on niagra (sparc64) with gcc 4.3.2
  src/factor.c: In function 'factor_using_pollard_rho2':
  src/factor.c:1535: warning: right shift count >= width of type
  src/factor.c:1558: warning: right shift count >= width of type
  src/factor.c:1568: warning: right shift count >= width of type

These warnings are alleviated with:

diff --git a/src/factor.c b/src/factor.c
index 73c59e9..e842556 100644
--- a/src/factor.c
+++ b/src/factor.c
@@ -1532,7 +1533,7 @@ factor_using_pollard_rho2 (uintmax_t n1, uintmax_t n0, 
unsigned long int a,
             {
               x0 = mulredc2 (&r1m, x1, x0, x1, x0, n1, n0, ni);
               x1 = r1m;
-              addmod2 (x1, x0, x1, x0, 0, a, n1, n0);
+              addmod2 (x1, x0, x1, x0, 0, (uintmax_t) a, n1, n0);

               submod2 (t1, t0, z1, z0, x1, x0, n1, n0);
               P0 = mulredc2 (&r1m, P1, P0, t1, t0, n1, n0, ni);
@@ -1555,7 +1556,7 @@ factor_using_pollard_rho2 (uintmax_t n1, uintmax_t n0, 
unsigned long int a,
             {
               x0 = mulredc2 (&r1m, x1, x0, x1, x0, n1, n0, ni);
               x1 = r1m;
-              addmod2 (x1, x0, x1, x0, 0, a, n1, n0);
+              addmod2 (x1, x0, x1, x0, 0, (uintmax_t) a, n1, n0);
             }
           y1 = x1; y0 = x0;
         }
@@ -1565,7 +1566,7 @@ factor_using_pollard_rho2 (uintmax_t n1, uintmax_t n0, 
unsigned long int a,
         {
           y0 = mulredc2 (&r1m, y1, y0, y1, y0, n1, n0, ni);
           y1 = r1m;
-          addmod2 (y1, y0, y1, y0, 0, a, n1, n0);
+          addmod2 (y1, y0, y1, y0, 0, (uintmax_t) a, n1, n0);

           submod2 (t1, t0, z1, z0, y1, y0, n1, n0);
           g0 = gcd2_odd (&g1, t1, t0, n1, n0);

  /tmp/ccjv79Tn.s:8713: Error: Architecture mismatch on "addc".
  /tmp/ccjv79Tn.s:8713:  (Requires v9|v9a|v9b; requested architecture is 
sparclite.)
  /tmp/ccjv79Tn.s:8755: Error: Architecture mismatch on "subccc".
  /tmp/ccjv79Tn.s:8755:  (Requires v9|v9a|v9b; requested architecture is 
sparclite.)
  /tmp/ccjv79Tn.s:8756: Error: Architecture mismatch on "subc".
  /tmp/ccjv79Tn.s:8756:  (Requires v9|v9a|v9b; requested architecture is 
sparclite.)

So gcc on sparc defaults to v7, I.E. the most compatible,
and the compile succeeds with CFLAGS=-mcpu=niagara.
So it seems best to protect these V9 specific instructions with:

diff --git a/src/longlong.h b/src/longlong.h
-#if defined (__sparc__) && W_TYPE_SIZE == 64
+#if (defined (__sparc_v9) || defined (__sparc_v9__)) && W_TYPE_SIZE == 64
 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \

Note I itemized the various distinguishing definitions available using:

$ for cpu in 'v7' 'cypress' 'v8' 'supersparc' 'sparclite' 'f930' 'f934' 
'hypersparc' \
   'sparclite86x' 'sparclet' 'tsc701' 'v9' 'ultrasparc' 'ultrasparc3' 'niagara' 
'niagara2'; do
  echo "--------- $cpu --------"
  cpp -mcpu=$cpu -dM /dev/null |
  grep -Ei '(sparc|niagra)' | grep -Ev 'sparc( |__)'
done

--------- v7 --------
--------- cypress --------
--------- v8 --------
#define __sparc_v8__ 1
--------- supersparc --------
#define __sparc_v8__ 1
--------- sparclite --------
#define __sparclite__ 1
--------- f930 --------
#define __sparclite__ 1
--------- f934 --------
#define __sparclite__ 1
--------- hypersparc --------
#define __sparc_v8__ 1
--------- sparclite86x --------
#define __sparclite86x__ 1
--------- sparclet --------
#define __sparclet__ 1
--------- tsc701 --------
#define __sparclet__ 1
--------- v9 --------
#define __sparc_v9__ 1
--------- ultrasparc --------
#define __sparc_v9__ 1
--------- ultrasparc3 --------
#define __sparc_v9__ 1
--------- niagara --------
#define __sparc_v9__ 1
--------- niagara2 --------
#define __sparc_v9__ 1

cheers,
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]