x86: Set optimize to INT_MAX for -Os
authorH.J. Lu <hjl.tools@gmail.com>
Sat, 16 Mar 2019 23:39:18 +0000 (07:39 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Sat, 16 Mar 2019 23:49:06 +0000 (07:49 +0800)
Set optimize to INT_MAX, instead of -1, for -Os so that -Os will include
-O2 optimization.

PR gas/24353
* config/tc-i386.c (md_parse_option): Set optimize to INT_MAX
for -Os.
* testsuite/gas/i386/optimize-2.s: Add a test.
* testsuite/gas/i386/x86-64-optimize-3.s: Likewise.
* testsuite/gas/i386/optimize-2.d: Updated.
* testsuite/gas/i386/x86-64-optimize-3.d: Likewise.

gas/ChangeLog
gas/config/tc-i386.c
gas/testsuite/gas/i386/optimize-2.d
gas/testsuite/gas/i386/optimize-2.s
gas/testsuite/gas/i386/x86-64-optimize-3.d
gas/testsuite/gas/i386/x86-64-optimize-3.s

index e3cba86a0d6f658488e959e924ef80699dde6191..e5907d1b5a9d28619a4aaedcbb0c7bd0ee6f978c 100644 (file)
@@ -1,3 +1,15 @@
+2019-03-17  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gas/24353
+       * config/tc-i386.c: Include <limits.h> if it exists and try
+       including <sys/param.h> if we have it.
+       (INT_MAX): Define if not defined.
+       (md_parse_option): Set optimize to INT_MAX for -Os.
+       * testsuite/gas/i386/optimize-2.s: Add a test.
+       * testsuite/gas/i386/x86-64-optimize-3.s: Likewise.
+       * testsuite/gas/i386/optimize-2.d: Updated.
+       * testsuite/gas/i386/x86-64-optimize-3.d: Likewise.
+
 2019-03-17  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR gas/24352
index 959fda2b847ea76988bd463fce6bc669a4049c1e..8047ddf8b11cea7bca759ee4b18751b43cd36399 100644 (file)
 #include "elf/x86-64.h"
 #include "opcodes/i386-init.h"
 
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#else
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#ifndef INT_MAX
+#define INT_MAX (int) (((unsigned) (-1)) >> 1)
+#endif
+#endif
+
 #ifndef REGISTER_WARNINGS
 #define REGISTER_WARNINGS 1
 #endif
@@ -11350,7 +11361,7 @@ md_parse_option (int c, const char *arg)
        {
          optimize_for_space = 1;
          /* Turn on all encoding optimizations.  */
-         optimize = -1;
+         optimize = INT_MAX;
        }
       else
        {
index ec989b0e131d7e132015acc8a753620a6533eb17..e8a516997a603843590f40fdcb97dce07e2c1265 100644 (file)
@@ -16,4 +16,5 @@ Disassembly of section .text:
  +[a-f0-9]+:   f6 c3 7f                test   \$0x7f,%bl
  +[a-f0-9]+:   f7 c7 7f 00 00 00       test   \$0x7f,%edi
  +[a-f0-9]+:   66 f7 c7 7f 00          test   \$0x7f,%di
+ +[a-f0-9]+:   c5 f1 55 e9             vandnpd %xmm1,%xmm1,%xmm5
 #pass
index b427a741b98ca8b700ace12a4321e2c16a330fae..c9b57a8dd163f73be3f139d211c0d74de5568de3 100644 (file)
@@ -11,3 +11,5 @@ _start:
        test    $0x7f, %bl
        test    $0x7f, %edi
        test    $0x7f, %di
+
+       vandnpd %zmm1, %zmm1, %zmm5
index b46f728dd82fc94f42a02e051602364db800b83c..f85c0af05e385b4bf9669d13a9028af8a1e5feaf 100644 (file)
@@ -24,4 +24,5 @@ Disassembly of section .text:
  +[a-f0-9]+:   41 f6 c1 7f             test   \$0x7f,%r9b
  +[a-f0-9]+:   41 f6 c1 7f             test   \$0x7f,%r9b
  +[a-f0-9]+:   41 f6 c1 7f             test   \$0x7f,%r9b
+ +[a-f0-9]+:   c5 f1 55 e9             vandnpd %xmm1,%xmm1,%xmm5
 #pass
index 61c150a87c8083f97753651eca5356824cc7a48e..4a52a25ddd02e3d9d4c923af607e4dc552df997d 100644 (file)
@@ -19,3 +19,5 @@ _start:
        test    $0x7f, %r9d
        test    $0x7f, %r9w
        test    $0x7f, %r9b
+
+       vandnpd %zmm1, %zmm1, %zmm5