public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/60206] New: IVOPT has no idea of inline asm
@ 2014-02-14 21:52 wmi at google dot com
  2014-02-14 22:08 ` [Bug tree-optimization/60206] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: wmi at google dot com @ 2014-02-14 21:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60206

            Bug ID: 60206
           Summary: IVOPT has no idea of inline asm
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wmi at google dot com
                CC: rguenth at gcc dot gnu.org, shenhan at google dot com
              Host: i386
            Target: i386

Created attachment 32141
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32141&action=edit
Testcase

This bug is found in google branch but I think the same problem also exists on
trunk (but not exposed).

For the testcase 1.c attached (1.c is extracted from libgcc/soft-fp/divtf3.c),
use trunk compiler gcc-r202164 (Target: x86_64-unknown-linux-gnu) + the patch
r204497 could expose the problem.

The command:
gcc -v -O2 -fno-omit-frame-pointer -fpic -c -S -m32 1.c

The error:
./1.c: In function ‘__divtf3’:
./1.c:64:1194: error: ‘asm’ operand has impossible constraints

The inline asm in error message is as follow:
do {
 __asm__ (
"sub{l} {%11,%3|%3,%11}\n\t"
"sbb{l} {%9,%2|%2,%9}\n\t"
"sbb{l} {%7,%1|%1,%7}\n\t"
"sbb{l} {%5,%0|%0,%5}"
: "=r" ((USItype) (A_f[3])), "=&r" ((USItype) (A_f[2])), "=&r" ((USItype)
(A_f[1])), "=&r" ((USItype) (A_f[0])) : "0" ((USItype) (B_f[2])), "g"
((USItype) (A_f[2])), "1" ((USItype) (B_f[1])), "g" ((USItype) (A_f[1])), "2"
((USItype) (B_f[0])), "g" ((USItype) (A_f[0])), "3" ((USItype) (0)), "g"
((USItype) (_n_f[_i])));
} while ()

Because -fno-omit-frame-pointer is turned on and the command line uses -fpic,
there are only 5 registers for register allocation.

Before IVOPT,
%0, %1, %2, %3 require 4 registers. The index variable i of _n_f[_i] requires
another register. So 5 registers are used up here.

After IVOPT, MEM reference _n_f[_i] is converted to MEM[base: _874, index:
ivtmp.22_821, offset: 0B]. base and index require 2 registers, Now 6 registers
are required, so LRA cannot find enough registers to allocate.

trunk compiler doesn't expose the problem because of patch r202165. With patch
r202165, IVOPT doesn't change _n_f[_i] in inline asm above. But it just hided
the problem.

Should IVOPT care about the constraints in inline-asm and restrict its
optimization in some case?
>From gcc-bugs-return-443613-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Feb 14 22:02:13 2014
Return-Path: <gcc-bugs-return-443613-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 7939 invoked by alias); 14 Feb 2014 22:02:12 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 7853 invoked by uid 48); 14 Feb 2014 22:02:08 -0000
From: "hjl.tools at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/60207] New: Wrong TFmode check in construct_container
Date: Fri, 14 Feb 2014 22:02:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: hjl.tools at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc
Message-ID: <bug-60207-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-02/txt/msg01370.txt.bz2
Content-length: 3461

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`207

            Bug ID: 60207
           Summary: Wrong TFmode check in construct_container
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
                CC: hubicka at ucw dot cz, rth at gcc dot gnu.org, ubizjak at gmail dot com

r73099:

commit e07e720e6332466eef5d5f0ad7687523ddbfc644
Author: hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Thu Oct 30 21:01:16 2003 +0000

      * real.c (encode_ieee_extended): Initialize whole array.
      * reg-stack.c (move_for_stack_reg0: Use always XFmode.
      * i386-modes.def: Change definitions of TFmode and XFmode.
      * i386.c (classify_argument): Rename TFmodes to XFmodes; add new TFmode
co
de.
      (construct_container): Allow constructing of TFmode integer containers.
      (ix86_return_in_memory):  XFmode is not returned in memory.
      (init_ext_80387_constants): Always use XFmode.
      (print_operand): Likewise.
      (ix86_prepare_fp_compare_regs): Likewise.
      (split_to_parts): Deal with TFmode.
      (split_long_move): Simplify.
      (ix86_init_mmx_sse_builtins): Add __float80, __float128.
      (ix86_memory_move_cost): Do not confuse TFmode.
      * i386.h (LONG_DOUBLE_TYPE_SIZE): Set to 96.
      (IS_STACK_MODE): TFmode is not stack mode.
      (HARD_REGNO_NREGS, CLASS_MAX_NREGS): Deal nicely with XFmode.
      (VALID_SSE_REG_MODE): Allow TFmode.
      (VALID_FP_MODE_P): Disallow TFmode.

passed TFmode in integer registers:

+    case TFmode:
+      classes[0] = X86_64_INTEGER_CLASS;
+      classes[1] = X86_64_INTEGER_CLASS;
+      return 2;

   if (n == 2 && class[0] == X86_64_INTEGER_CLASS
       && class[1] == X86_64_INTEGER_CLASS
-      && (mode == CDImode || mode == TImode)
+      && (mode == CDImode || mode == TImode || mode == TFmode)
       && intreg[0] + 1 == intreg[1])
     return gen_rtx_REG (mode, intreg[0]);

But it was changed later to pass TFmode in SSE register:

commit fabb8546e54830051300c70ddcd8a6fce3b7d790
Author: rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Jul 9 22:35:35 2004 +0000

            * config/i386/i386.c (classify_argument): Treat V1xx modes the same
as
            their base modes. CTImode, TCmode, and XCmode must be passed in
memory.
            TFmode (__float128) must be is an SSE/SSEUP pair. V2SImode,
V4HImode,
            and V8QI are class SSE. All sufficiently small remaining vector
modes
            must be passed in one or two integer registers.
            (ix86_libcall_value): TFmode must be returned in xmm0, XCmode must
be
            returned in memory.
            (bdesc_2arg, ix86_init_mmx_sse_builtins): __builtin_ia32_pmuludq
and
            __builtin_ia32_pmuludq128 have non-uniform argument and return
types
            and must thus be handled explicitly.
            * config/i386/i386.md (*movdi_1_rex64): Add cases for moving
between
            MMX and XMM regs.
            (movv8qi_internal, movv4hi_internal, movv2si_internal,
            movv2sf_internal): Permit moving between MMX and XMM registers
(since
            MMX areguments and return values are passed in XMM registers).
            (sse2_umulsidi3): Correct type and mode.

But we didn't remove mode == TFmode check in construct_container.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-03-13 20:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-14 21:52 [Bug tree-optimization/60206] New: IVOPT has no idea of inline asm wmi at google dot com
2014-02-14 22:08 ` [Bug tree-optimization/60206] " pinskia at gcc dot gnu.org
2014-02-14 22:22 ` wmi at google dot com
2014-02-15  0:52 ` joseph at codesourcery dot com
2014-02-15  2:20 ` wmi at google dot com
2014-02-17  9:58 ` rguenther at suse dot de
2014-03-10 20:59 ` wmi at google dot com
2014-03-10 21:00 ` wmi at google dot com
2014-03-13 20:22 ` olegendo at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).