[Bug inline-asm/64681] New: gcc assign wrong register for arm inline assembly

2015-01-19 Thread zhongwei.yao at arm dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64681

Bug ID: 64681
   Summary: gcc assign wrong register for arm inline assembly
   Product: gcc
   Version: 4.9.0
Status: UNCONFIRMED
  Severity: blocker
  Priority: P3
 Component: inline-asm
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhongwei.yao at arm dot com

Created attachment 34492
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34492&action=edit
all related file.

I compile following code on linux by arm-linux-androideabi-gcc (gcc version 4.9
20140827) with following command:

 arm-linux-androideabi-g++ -mfloat-abi=softfp -mfpu=neon -mthumb -Wall -Wextra
-march=armv7-a --sysroot=$ndk/platforms/android-21/arch-arm -O2 -Wall main.cpp

==c code start==
#include 

int main(void) {
  return 0;
}

char buffer[32];

void bar(int n) {
  int j = 0;
  int64x1_t s = vdup_n_s64(0);
  int64x1_t onev = vdup_n_s64(1);
  int64_t sum = 0;

  for (j = 0; j <= n; j++) {
asm ("vsub.s64 %0, %0, d1"
  : "+w" (s): : "memory");
  }
  sum = (int64_t)j;
  sum >>= vget_lane_s64(s, 0);
  if(sum >0)
s = vsub_s64(s, onev);
  vst1_s64((int64_t*)buffer, s);
}
==code end==

It returns:
/tmp/ccE0j9sL.s: Assembler messages:
/tmp/ccE0j9sL.s:55: Error: invalid instruction shape -- `vsub.s64 s14,s14,d1'

I think it is the bug in gcc that assign wrong register for variable s. It
should be d14 here, while it assignes s14.

The generated assembly file is:

==asm code start==
.syntax unified
.arch armv7-a
.eabi_attribute 27, 3
.fpu neon
.eabi_attribute 20, 1
.eabi_attribute 21, 1
.eabi_attribute 23, 3
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.eabi_attribute 26, 2
.eabi_attribute 30, 2
.eabi_attribute 34, 1
.eabi_attribute 18, 4
.thumb
.file"main.cpp"
.section.text.startup,"ax",%progbits
.align2
.globalmain
.thumb
.thumb_func
.typemain, %function
main:
.fnstart
.LFB1870:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
movsr0, #0
bxlr
.cantunwind
.fnend
.sizemain, .-main
.text
.align2
.global_Z3bari
.thumb
.thumb_func
.type_Z3bari, %function
_Z3bari:
.fnstart
.LFB1871:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
cmpr0, #0
vmov.i32d7, #0  @ di
push{lr}
blt.L5
addsr0, r0, #1
movsr2, #0
.L4:
addsr2, r2, #1
cmpr2, r0
#APP
@ 17 "src/main.cpp" 1
vsub.s64 s14, s14, d1
@ 0 "" 2
.thumb
bne.L4
fmrsr1, s14@ int
asrsr3, r2, #31
rsbr0, r1, #32
subslr, r1, #32
lslr0, r3, r0
lsrr2, r2, r1
itpl
asrpllr, r3, lr
orrr2, r2, r0
itpl
orrplr2, r2, lr
asrsr3, r3, r1
cmpr2, #1
sbcsr3, r3, #0
blt.L5
vmov.i32d16, #0x  @ di
vadd.i64d7, d7, d16
.L5:
ldrr3, .L10
.LPIC1:
addr3, pc
ldrr3, [r3]
vst1.64{d7}, [r3:64]
ldrpc, [sp], #4
.L11:
.align2
.L10:
.wordbuffer(GOT_PREL)+(.-(.LPIC1+4))
.cantunwind
.fnend
.size_Z3bari, .-_Z3bari
.globalbuffer
.bss
.align3
.typebuffer, %object
.sizebuffer, 32
buffer:
.space32
.ident"GCC: (GNU) 4.9 20140827 (prerelease)"
.section.note.GNU-stack,"",%progbits
==asm code end==


[Bug inline-asm/64681] gcc assign wrong register for arm inline assembly

2015-01-20 Thread zhongwei.yao at arm dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64681

zhongwei.yao  changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |---

--- Comment #3 from zhongwei.yao  ---
(In reply to Andreas Schwab from comment #1)
> You need to format the operand as %P0.

Hi, Andreas, Thanks for pointing out this. Is this syntax documented in GCC
doc?


[Bug inline-asm/64681] Document print modifiers for ARM

2015-01-26 Thread zhongwei.yao at arm dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64681

zhongwei.yao  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WORKSFORME

--- Comment #5 from zhongwei.yao  ---
(In reply to David from comment #4)
> Until very recently, *none* of the modifiers were documented.  In the
> current docs
> (https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#i386Operandmodifiers),
> only the i386 modifiers are doc'ed.
> 
> That said, you can always check out the gcc source.  For example:
> 
> The comments above output_asm_insn in
> https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/final.c?view=co&content-
> type=text%2Fplain describe some global modifiers.
> 
> For i386-specific modifiers, look above ix86_print_operand in
> https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/config/i386/i386.c?view=co&content-
> type=text%2Fplain
> 
> For arm, look above arm_print_operand in
> https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/config/arm/arm.c?view=co&content-
> type=text%2Fplain
> 
> Presumably there are similar sections for other configs.

Thanks!