public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/102182] New: Runtime error for gcc.dg/torture/fp-int-convert-float16.c
@ 2021-09-03  5:56 crazylht at gmail dot com
  2021-09-03  5:57 ` [Bug target/102182] " crazylht at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: crazylht at gmail dot com @ 2021-09-03  5:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102182

            Bug ID: 102182
           Summary: Runtime error for
                    gcc.dg/torture/fp-int-convert-float16.c
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-*-* i?86-*-*

I got

FAIL: gcc.dg/torture/fp-int-convert-float16.c   -Os  execution test
FAIL: gcc.dg/torture/fp-int-convert-float16-timode.c   -Os  execution test

with -m32:

[hjl@gnu-skx-1 gcc]$ ./xgcc -B./ -m32
/export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/torture/fp-int-convert-float16.c
 -m32  -Os -march=i686 -mfpmath=sse -msse2
[hjl@gnu-skx-1 gcc]$ ./a.out
Aborted (core dumped)
[hjl@gnu-skx-1 gcc]$

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

* [Bug target/102182] Runtime error for gcc.dg/torture/fp-int-convert-float16.c
  2021-09-03  5:56 [Bug target/102182] New: Runtime error for gcc.dg/torture/fp-int-convert-float16.c crazylht at gmail dot com
@ 2021-09-03  5:57 ` crazylht at gmail dot com
  2021-09-03  6:17 ` crazylht at gmail dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: crazylht at gmail dot com @ 2021-09-03  5:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102182

Hongtao.liu <crazylht at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hjl.tools at gmail dot com

--- Comment #1 from Hongtao.liu <crazylht at gmail dot com> ---
I’m still trying to reduce a small testcase.

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

* [Bug target/102182] Runtime error for gcc.dg/torture/fp-int-convert-float16.c
  2021-09-03  5:56 [Bug target/102182] New: Runtime error for gcc.dg/torture/fp-int-convert-float16.c crazylht at gmail dot com
  2021-09-03  5:57 ` [Bug target/102182] " crazylht at gmail dot com
@ 2021-09-03  6:17 ` crazylht at gmail dot com
  2021-09-03  6:39 ` crazylht at gmail dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: crazylht at gmail dot com @ 2021-09-03  6:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102182

--- Comment #2 from Hongtao.liu <crazylht at gmail dot com> ---
Reproduced case.

#include<stdlib.h>
int
main (void)
{
  static volatile unsigned int ivin, ivout;
  static volatile _Float16 fv1, fv2;
  ivin = ((unsigned int)1);
  fv1 = ((unsigned int)1);
  fv2 = ivin;
  ivout = fv2;
  if (ivout != ((unsigned int)1))
    abort ();

  exit (0);
}

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

* [Bug target/102182] Runtime error for gcc.dg/torture/fp-int-convert-float16.c
  2021-09-03  5:56 [Bug target/102182] New: Runtime error for gcc.dg/torture/fp-int-convert-float16.c crazylht at gmail dot com
  2021-09-03  5:57 ` [Bug target/102182] " crazylht at gmail dot com
  2021-09-03  6:17 ` crazylht at gmail dot com
@ 2021-09-03  6:39 ` crazylht at gmail dot com
  2021-09-03  7:08 ` marxin at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: crazylht at gmail dot com @ 2021-09-03  6:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102182

--- Comment #3 from Hongtao.liu <crazylht at gmail dot com> ---
during pass_expand we got

(debug_insn 24 23 0 (debug_marker) "test1.c":10:3 -1
     (nil))
;; fv2.1_3 ={v} fv2;

(insn 25 24 0 (set (reg:HF 84 [ fv2.1_3 ])
        (mem/v/c:HF (symbol_ref:SI ("fv2.1") [flags 0x2]  <var_decl
0x7f1f0ae4c000 fv2>) [2 fv2+0 S2 A16])) "test1.c":10:9 -1
     (nil))

;; _4 = (unsigned int) fv2.1_3;

(insn 31 25 32 (parallel [
            (set (reg:DI 94)
                (fix:DI (reg:SF 93)))
            (clobber (reg:CC 17 flags))
        ]) "test1.c":10:9 -1
     (nil))

But __extendhfsf2 is ommited under -Os, 

For -O2 expand does the right thing

;; fv2.1_3 ={v} fv2;

(insn 17 16 0 (set (reg:HF 84 [ fv2.1_3 ])
        (mem/v/c:HF (symbol_ref:SI ("fv2.1") [flags 0x2]  <var_decl
0x7f166dab4360 fv2>) [2 fv2+0 S2 A16])) "test1.c":10:9 -1
     (nil))

;; _4 = (unsigned int) fv2.1_3;


(insn 18 17 19 (set (mem:HF (reg/f:SI 79 virtual-outgoing-args) [0  S2 A32])
        (reg:HF 84 [ fv2.1_3 ])) "test1.c":10:9 -1
     (nil))

(call_insn/u 19 18 20 (set (reg:SF 8 st)
        (call (mem:QI (symbol_ref:SI ("__extendhfsf2") [flags 0x41] 
<function_decl 0x7f166dac5000 __extendhfsf2>) [0  S1 A8])
            (const_int 16 [0x10]))) "test1.c":10:9 -1
     (expr_list:REG_CALL_DECL (symbol_ref:SI ("__extendhfsf2") [flags 0x41] 
<function_decl 0x7f166dac5000 __extendhfsf2>)
        (expr_list:REG_EH_REGION (const_int -2147483648 [0xffffffff80000000])
            (nil)))
    (expr_list (use (mem:HF (reg/f:SI 79 virtual-outgoing-args) [0  S2 A8]))
        (nil)))

(insn 20 19 21 (set (reg:SF 93)
        (reg:SF 8 st)) "test1.c":10:9 -1
     (expr_list:REG_EQUAL (float_extend:SF (reg:HF 84 [ fv2.1_3 ]))
        (nil)))

(insn 21 20 22 (set (reg:V4SF 95)
        (vec_duplicate:V4SF (mem/u/c:SF (symbol_ref/u:SI ("*.LC3") [flags 0x2])
[0  S4 A32]))) "test1.c":10:9 7413 {vec_dupv4sf}
     (nil))

(insn 22 21 23 (set (reg:V4SF 94)
        (reg:V4SF 95)) "test1.c":10:9 -1
     (expr_list:REG_EQUAL (const_vector:V4SF [
                (const_double:SF 2.147483648e+9 [0x0.8p+32]) repeated x4
            ])
        (nil)))

(insn 23 22 0 (parallel [
            (set (reg:SI 85 [ _4 ])
                (unsigned_fix:SI (reg:SF 93)))
            (use (reg:V4SF 94))
            (clobber (scratch:V4SF))
            (clobber (scratch:V4SF))
        ]) "test1.c":10:9 -1
     (expr_list:REG_EQUAL (unsigned_fix:SI (reg:SF 93))
        (nil)))

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

* [Bug target/102182] Runtime error for gcc.dg/torture/fp-int-convert-float16.c
  2021-09-03  5:56 [Bug target/102182] New: Runtime error for gcc.dg/torture/fp-int-convert-float16.c crazylht at gmail dot com
                   ` (2 preceding siblings ...)
  2021-09-03  6:39 ` crazylht at gmail dot com
@ 2021-09-03  7:08 ` marxin at gcc dot gnu.org
  2021-09-03  7:38 ` crazylht at gmail dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-09-03  7:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102182

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-09-03
                 CC|                            |marxin at gcc dot gnu.org
     Ever confirmed|0                           |1

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

* [Bug target/102182] Runtime error for gcc.dg/torture/fp-int-convert-float16.c
  2021-09-03  5:56 [Bug target/102182] New: Runtime error for gcc.dg/torture/fp-int-convert-float16.c crazylht at gmail dot com
                   ` (3 preceding siblings ...)
  2021-09-03  7:08 ` marxin at gcc dot gnu.org
@ 2021-09-03  7:38 ` crazylht at gmail dot com
  2021-09-06 10:58 ` cvs-commit at gcc dot gnu.org
  2021-09-06 10:58 ` crazylht at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: crazylht at gmail dot com @ 2021-09-03  7:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102182

--- Comment #4 from Hongtao.liu <crazylht at gmail dot com> ---
After emit libcall in convert_to_mode, it failed maybe_emit_unop_insn, so all
insns deleted, but from here is already overrided, it seems to be a bug.

        if (icode != CODE_FOR_nothing)
          {
            rtx_insn *last = get_last_insn ();
            if (fmode != GET_MODE (from))
              from = convert_to_mode (fmode, from, 0);

            if (must_trunc)
              {
                rtx temp = gen_reg_rtx (GET_MODE (from));
                from = expand_unop (GET_MODE (from), ftrunc_optab, from,
                                    temp, 0);
              }

            if (imode != GET_MODE (to))
              target = gen_reg_rtx (imode);

            if (maybe_emit_unop_insn (icode, target, from,
                                      doing_unsigned ? UNSIGNED_FIX : FIX))
              {
                if (target != to)
                  convert_move (to, target, unsignedp);
                return;
              }
            delete_insns_since (last);
          }

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

* [Bug target/102182] Runtime error for gcc.dg/torture/fp-int-convert-float16.c
  2021-09-03  5:56 [Bug target/102182] New: Runtime error for gcc.dg/torture/fp-int-convert-float16.c crazylht at gmail dot com
                   ` (4 preceding siblings ...)
  2021-09-03  7:38 ` crazylht at gmail dot com
@ 2021-09-06 10:58 ` cvs-commit at gcc dot gnu.org
  2021-09-06 10:58 ` crazylht at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-09-06 10:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102182

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by hongtao Liu <liuhongt@gcc.gnu.org>:

https://gcc.gnu.org/g:93e6809459f34ca7b5928f1729246b2e9dfb3eb4

commit r12-3368-g93e6809459f34ca7b5928f1729246b2e9dfb3eb4
Author: liuhongt <hongtao.liu@intel.com>
Date:   Mon Sep 6 17:09:38 2021 +0800

    Avoid FROM being overwritten in expand_fix.

    For the conversion from _Float16 to int, if the corresponding optab
    does not exist, the compiler will try the wider mode (SFmode here),
    but when floatsfsi exists but FAIL, FROM will be rewritten, which
    leads to a PR runtime error.

    gcc/ChangeLog:

            PR middle-end/102182
            * optabs.c (expand_fix): Add from1 to avoid from being
            overwritten.

    gcc/testsuite/ChangeLog:

            PR middle-end/102182
            * gcc.target/i386/pr101282.c: New test.

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

* [Bug target/102182] Runtime error for gcc.dg/torture/fp-int-convert-float16.c
  2021-09-03  5:56 [Bug target/102182] New: Runtime error for gcc.dg/torture/fp-int-convert-float16.c crazylht at gmail dot com
                   ` (5 preceding siblings ...)
  2021-09-06 10:58 ` cvs-commit at gcc dot gnu.org
@ 2021-09-06 10:58 ` crazylht at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: crazylht at gmail dot com @ 2021-09-06 10:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102182

Hongtao.liu <crazylht at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Hongtao.liu <crazylht at gmail dot com> ---
Fixed in GCC12.

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

end of thread, other threads:[~2021-09-06 10:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03  5:56 [Bug target/102182] New: Runtime error for gcc.dg/torture/fp-int-convert-float16.c crazylht at gmail dot com
2021-09-03  5:57 ` [Bug target/102182] " crazylht at gmail dot com
2021-09-03  6:17 ` crazylht at gmail dot com
2021-09-03  6:39 ` crazylht at gmail dot com
2021-09-03  7:08 ` marxin at gcc dot gnu.org
2021-09-03  7:38 ` crazylht at gmail dot com
2021-09-06 10:58 ` cvs-commit at gcc dot gnu.org
2021-09-06 10:58 ` crazylht at gmail dot com

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).