]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/5g, cmd/6g, cmd/8g: remove width check for componentgen.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Thu, 1 Nov 2012 13:36:08 +0000 (14:36 +0100)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Thu, 1 Nov 2012 13:36:08 +0000 (14:36 +0100)
The move to 64-bit ints in 6g made componentgen ineffective.
In componentgen, the code already selects which values it can handle.

On amd64:
benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    9477970000   9582314000   +1.10%
BenchmarkFannkuch11      5928750000   5255080000  -11.36%
BenchmarkGobDecode         37103040     31451120  -15.23%
BenchmarkGobEncode         16042490     16844730   +5.00%
BenchmarkGzip             811337400    741373600   -8.62%
BenchmarkGunzip           197928700    192844500   -2.57%
BenchmarkJSONEncode       224164100    140064200  -37.52%
BenchmarkJSONDecode       258346800    231829000  -10.26%
BenchmarkMandelbrot200      7561780      7601615   +0.53%
BenchmarkParse             12970340     11624360  -10.38%
BenchmarkRevcomp         1969917000   1699137000  -13.75%
BenchmarkTemplate         296182000    263117400  -11.16%

R=nigeltao, dave, daniel.morsing
CC=golang-dev
https://golang.org/cl/6821052

src/cmd/5g/cgen.c
src/cmd/5g/ggen.c
src/cmd/6g/cgen.c
src/cmd/6g/ggen.c
src/cmd/8g/cgen.c
src/cmd/8g/ggen.c

index 36aab03b110af3339747b5a5c56dd30a36418acc..fe8683b5d4e96c12b9a7822e3137bc0ac975aa2f 100644 (file)
@@ -1356,9 +1356,9 @@ sgen(Node *n, Node *res, int64 w)
                return;
        }
 
-       if(w == 8 || w == 12)
-               if(componentgen(n, res))
-                       return;
+       // Avoid taking the address for simple enough types.
+       if(componentgen(n, res))
+               return;
        
        // determine alignment.
        // want to avoid unaligned access, so have to use
@@ -1495,9 +1495,10 @@ cadable(Node *n)
 }
 
 /*
- * copy a structure component by component
+ * copy a composite value by moving its individual components.
+ * Slices, strings and interfaces are supported.
+ * nr is N when assigning a zero value.
  * return 1 if can do, 0 if cant.
- * nr is N for copy zero
  */
 int
 componentgen(Node *nr, Node *nl)
index 32caf0c9035356aeb200dd9c2719fe9187c95e60..a60f414943baada2e5c669019a5013d0896aa6fb 100644 (file)
@@ -618,9 +618,9 @@ clearfat(Node *nl)
 
 
        w = nl->type->width;
-       if(w == 8 || w == 12)
-               if(componentgen(N, nl))
-                       return;
+       // Avoid taking the address for simple enough types.
+       if(componentgen(N, nl))
+               return;
 
        c = w % 4;      // bytes
        q = w / 4;      // quads
index 0d8ce468a45fdbddd2a27fe2449d83f0e1aac17a..195011ae908acab9daba2c30dc04641475ef3f75 100644 (file)
@@ -1254,9 +1254,9 @@ sgen(Node *n, Node *ns, int64 w)
        if(w < 0)
                fatal("sgen copy %lld", w);
 
-       if(w == 16)
-               if(componentgen(n, ns))
-                       return;
+       // Avoid taking the address for simple enough types.
+       if(componentgen(n, ns))
+               return;
        
        if(w == 0) {
                // evaluate side effects only
@@ -1378,9 +1378,10 @@ cadable(Node *n)
 }
 
 /*
- * copy a structure component by component
+ * copy a composite value by moving its individual components.
+ * Slices, strings and interfaces are supported.
+ * nr is N when assigning a zero value.
  * return 1 if can do, 0 if cant.
- * nr is N for copy zero
  */
 int
 componentgen(Node *nr, Node *nl)
index 74fd0f7c7cb406809734c0066c6105124f4aaa53..729dda4f281c93c926593e59d35db2f677448cb7 100644 (file)
@@ -1028,9 +1028,9 @@ clearfat(Node *nl)
 
 
        w = nl->type->width;
-       if(w == 16)
-               if(componentgen(N, nl))
-                       return;
+       // Avoid taking the address for simple enough types.
+       if(componentgen(N, nl))
+               return;
 
        c = w % 8;      // bytes
        q = w / 8;      // quads
index 04324b64957f9b5b1dfc4571e9c78647a4e98979..7b44bac0d3124417305ff522165c510b2464ec7d 100644 (file)
@@ -1276,10 +1276,9 @@ sgen(Node *n, Node *res, int64 w)
                return;
        }
 
-       if (w == 8 || w == 12) {
-               if(componentgen(n, res))
-                       return;
-       }
+       // Avoid taking the address for simple enough types.
+       if(componentgen(n, res))
+               return;
 
        // offset on the stack
        osrc = stkof(n);
@@ -1381,9 +1380,10 @@ cadable(Node *n)
 }
 
 /*
- * copy a structure component by component
+ * copy a composite value by moving its individual components.
+ * Slices, strings and interfaces are supported.
+ * nr is N when assigning a zero value.
  * return 1 if can do, 0 if cant.
- * nr is N for copy zero
  */
 int
 componentgen(Node *nr, Node *nl)
index ba09f597327e09b1222650791e4d01a237a23322..5ebd3b417c56a207a8f008b75380c8f67cfa5915 100644 (file)
@@ -59,9 +59,9 @@ clearfat(Node *nl)
                dump("\nclearfat", nl);
 
        w = nl->type->width;
-       if(w == 8 || w == 12)
-               if(componentgen(N, nl))
-                       return;
+       // Avoid taking the address for simple enough types.
+       if(componentgen(N, nl))
+               return;
 
        c = w % 4;      // bytes
        q = w / 4;      // quads