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

            Bug ID: 84985
           Summary: internal compiler error: in match_reload, at
                    lra-constraints.c:1068
           Product: gcc
           Version: 8.0.1
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: inline-asm
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vegard.nossum at oracle dot com
  Target Milestone: ---

Input:

int main() {
  int a;
  asm("" : "=d"(a) : "0"(a), "0ae"(&a));
}

Output:

$ cc1plus 
 int main()
Analyzing compilation unit
Performing interprocedural optimizations
 <*free_lang_data> <visibility> <build_ssa_passes> <opt_local_passes>
<targetclone> <free-fnsummary> <whole-program> <fnsummary> <inline>
<free-fnsummary> <single-use> <comdats>Assembling functions:
 <materialize-all-clones> <simdclone> int main()during RTL pass: reload

<stdin>: In function 'int main()':
<stdin>:4:1: internal compiler error: in match_reload, at
lra-constraints.c:1068
0x287e277 match_reload
        /home/vegard/git/gcc/gcc/lra-constraints.c:1066
0x28ade79 curr_insn_transform
        /home/vegard/git/gcc/gcc/lra-constraints.c:4335
0x28b93b6 lra_constraints(bool)
        /home/vegard/git/gcc/gcc/lra-constraints.c:4877
0x2829984 lra(_IO_FILE*)
        /home/vegard/git/gcc/gcc/lra.c:2419
0x2608794 do_reload
        /home/vegard/git/gcc/gcc/ira.c:5465
0x2608794 execute
        /home/vegard/git/gcc/gcc/ira.c:5649
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.

Version:

GNU C++14 (GCC) version 8.0.1 20180306 (experimental) (x86_64-pc-linux-gnu)

7.3.0 seems to handle it and outputs:

main:
  pushq %rbp
  movq %rsp, %rbp
  movl -4(%rbp), %eax
  leaq -4(%rbp), %rcx
  movl %eax, %edx
  movl %edx, %eax
  movl %eax, -4(%rbp)
  movl $0, %eax
  popq %rbp
  ret

Clang says:

<source>:3:36: error: more than one input constraint matches the same output
'0'
  asm("" : "=d"(a) : "0"(a), "0ae"(&a));
                                   ^
<source>:3:26: note: constraint '0' is already present here
  asm("" : "=d"(a) : "0"(a), "0ae"(&a));
                         ^
1 error generated.
Compiler returned: 1

Reply via email to