public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/103926] New: "wQ" broken
@ 2022-01-06  2:10 aik at ozlabs dot ru
  2022-01-06  2:12 ` [Bug target/103926] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: aik at ozlabs dot ru @ 2022-01-06  2:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103926
           Summary: "wQ" broken
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: other
          Assignee: unassigned at gcc dot gnu.org
          Reporter: aik at ozlabs dot ru
                CC: segher at gcc dot gnu.org
  Target Milestone: ---
              Host: power8
            Target: powerpc64le-linux
             Build: 3b0ba97fafe8 (2 week old releases/gcc-11)

Using `wQ` constraint ("memory acceptable by `lq`") makes gcc crash. Note that
without "-O2" gcc gently fails (not sure why).

The issue recreates on gcc-11 from git and Ubuntu 2104's gcc (10.3.0-1ubuntu1).

[fstn1-p1 ~]$
/home/aik/pbuild/crossgcc/gcc-powerpc64le-linux-11.2.1-2.37.50-nolibc/bin/powerpc64le-linux-gcc
gccbug.c -o gccbug.o -O2
gccbug.c: In function ‘f’:
gccbug.c:6:1: error: unrecognizable insn:
    6 | }
      | ^
(insn 6 11 9 2 (parallel [
            (set (reg:TI 10 10 [orig:118 v ] [118])
                (asm_operands/v:TI ("lq %0, 0(%1)") ("=&r") 0 [
                        (mem/f/c:DI (reg:DI 9 9 [120]) [1 ptr+0 S8 A128])
                    ]
                     [
                        (asm_input:DI ("wQ") gccbug.c:5)
                    ]
                     [] gccbug.c:5))
            (clobber (reg:SI 98 ca))
        ]) "gccbug.c":5:2 -1
     (nil))
during RTL pass: postreload
gccbug.c:6:1: internal compiler error: in extract_constrain_insn, at
recog.c:2671
0x10190343 _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
        /home/aik/p/gcc/gcc/gcc/rtl-error.c:108
0x10190397 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
        /home/aik/p/gcc/gcc/gcc/rtl-error.c:116
0x1082fe6b extract_constrain_insn(rtx_insn*)
        /home/aik/p/gcc/gcc/gcc/recog.c:2671
0x107ea1bf reload_cse_simplify_operands
        /home/aik/p/gcc/gcc/gcc/postreload.c:407
0x107ebd5f reload_cse_simplify
        /home/aik/p/gcc/gcc/gcc/postreload.c:190
0x107ebd5f reload_cse_regs_1
        /home/aik/p/gcc/gcc/gcc/postreload.c:238
0x107edf7b reload_cse_regs
        /home/aik/p/gcc/gcc/gcc/postreload.c:66
0x107edf7b execute
        /home/aik/p/gcc/gcc/gcc/postreload.c:2359
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

[fstn1-p1 ~]$ cat gccbug.c 
void f(void)
{
        void *ptr;
        __int128 v;
        asm volatile("lq %0, 0(%1)" : "=&r" (v) : "wQ" (ptr));
}

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

* [Bug target/103926] "wQ" broken
  2022-01-06  2:10 [Bug other/103926] New: "wQ" broken aik at ozlabs dot ru
@ 2022-01-06  2:12 ` pinskia at gcc dot gnu.org
  2022-01-06  2:26 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-06  2:12 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
               Host|power8                      |
              Build|3b0ba97fafe8 (2 week old    |
                   |releases/gcc-11)            |
           Keywords|                            |inline-asm
          Component|other                       |target

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
3b0ba97fafe8 (2 week old releases/gcc-11)

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

* [Bug target/103926] "wQ" broken
  2022-01-06  2:10 [Bug other/103926] New: "wQ" broken aik at ozlabs dot ru
  2022-01-06  2:12 ` [Bug target/103926] " pinskia at gcc dot gnu.org
@ 2022-01-06  2:26 ` pinskia at gcc dot gnu.org
  2022-01-06  3:43 ` aik at ozlabs dot ru
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-06  2:26 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice-on-valid-code           |ice-on-invalid-code

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The constraint is not documented even because it looks like an internal only
one:
;; Lq/stq validates the address for load/store quad
(define_memory_constraint "wQ"
  "@internal Memory operand suitable for the load/store quad instructions."
  (match_operand 0 "quad_memory_operand"))


Note your inline-asm is broken but GCC should not be crashing.

I think the following will work:

__int128 f(void *ptr)
{
  __int128 v;
  asm volatile("lq %0, 0(%1)" : "=&r" (v) : "wQ" (*(__int128 *)ptr));
  return v;
}

But there still some other stuff that you need to do.
The constraint is failing because you don't have a memory passed to the
inline-asm only the register and it is the wrong size, it is a 64bit rather
than 128bit.

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

* [Bug target/103926] "wQ" broken
  2022-01-06  2:10 [Bug other/103926] New: "wQ" broken aik at ozlabs dot ru
  2022-01-06  2:12 ` [Bug target/103926] " pinskia at gcc dot gnu.org
  2022-01-06  2:26 ` pinskia at gcc dot gnu.org
@ 2022-01-06  3:43 ` aik at ozlabs dot ru
  2022-01-06  3:50 ` pinskia at gcc dot gnu.org
  2022-02-23 14:43 ` segher at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: aik at ozlabs dot ru @ 2022-01-06  3:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Alexey Kardashevskiy <aik at ozlabs dot ru> ---
Documented here:
https://dmalcolm.fedorapeople.org/gcc/2015-08-31/rst-experiment/how-to-use-inline-assembly-language-in-c-code.html

Your example does not compile either (but does not crash :) )
This one does compile:
asm volatile("lq %0, %1" : "=&r" (v) : "wQ" (*(__int128 *)ptr));

Anyway, I posted this bug because of the crash than anything else.

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

* [Bug target/103926] "wQ" broken
  2022-01-06  2:10 [Bug other/103926] New: "wQ" broken aik at ozlabs dot ru
                   ` (2 preceding siblings ...)
  2022-01-06  3:43 ` aik at ozlabs dot ru
@ 2022-01-06  3:50 ` pinskia at gcc dot gnu.org
  2022-02-23 14:43 ` segher at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-06  3:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Alexey Kardashevskiy from comment #3)
> Documented here:
> https://dmalcolm.fedorapeople.org/gcc/2015-08-31/rst-experiment/how-to-use-
> inline-assembly-language-in-c-code.html

Not documented in user's manual though:
https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Machine-Constraints.html#Machine-Constraints


It is documented in the internals manual which is be expected (it is not
supposed to be used by the user):
https://gcc.gnu.org/onlinedocs/gccint/Machine-Constraints.html#Machine-Constraints

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

* [Bug target/103926] "wQ" broken
  2022-01-06  2:10 [Bug other/103926] New: "wQ" broken aik at ozlabs dot ru
                   ` (3 preceding siblings ...)
  2022-01-06  3:50 ` pinskia at gcc dot gnu.org
@ 2022-02-23 14:43 ` segher at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: segher at gcc dot gnu.org @ 2022-02-23 14:43 UTC (permalink / raw)
  To: gcc-bugs

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

Segher Boessenkool <segher at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-02-23
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #5 from Segher Boessenkool <segher at gcc dot gnu.org> ---
Well, there are a few things going on here.

Firstly, perhaps we should document wQ, if there is no better way to provide
this functionality.  (That last part is not clear, atomic types should work
fine!)

Secondly, the testcase is just broken.  wQ is a memory constraint, so giving
non-memory as the operand cannot work (it has identity, copying to temporary
memory would be even more wrong!)  But our error is not so friendly.

Correcting the testcase to

===
void f(void)
{
        __int128 *ptr;
        __int128 v;
        asm volatile("lq %0,%1" : "=r" (v) : "wQ" (*ptr));
}
===

(ignoring the uninitialised variable), and passing -mcpu=power8 (without
which (or power9 etc.) wQ is never satisfiable by anything) works.  Not
having the -mcpu= gives "error: unrecognizable insn" which is a bit
misleading, or at least not helpful.

It *is* normal for GCC to ICE on certain problems with inline asm, but the
error message should not be so baffling.

Anyway, confirmed.

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

end of thread, other threads:[~2022-02-23 14:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-06  2:10 [Bug other/103926] New: "wQ" broken aik at ozlabs dot ru
2022-01-06  2:12 ` [Bug target/103926] " pinskia at gcc dot gnu.org
2022-01-06  2:26 ` pinskia at gcc dot gnu.org
2022-01-06  3:43 ` aik at ozlabs dot ru
2022-01-06  3:50 ` pinskia at gcc dot gnu.org
2022-02-23 14:43 ` segher 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).