[llvm-bugs] [Bug 26874] 65536 out of the range of constraint 'I'

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 8 22:09:29 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26874

Eric Christopher <echristo at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |echristo at gmail.com
         Resolution|---                         |WORKSFORME

--- Comment #2 from Eric Christopher <echristo at gmail.com> ---
With the testcase I've created from your report and current ToT it works for
me:

dzur:~/tmp> ~/builds/build-llvm/bin/clang -target aarch64-linux-gnu -S foo.c
-O0 -o -
    .text
    .file    "foo.c"
    .globl    arch_spin_trylock
    .p2align    2
    .type    arch_spin_trylock, at function
arch_spin_trylock:                      // @arch_spin_trylock
// BB#0:                                // %entry
    sub    sp, sp, #16             // =16
    str    x0, [sp, #8]
    ldr    x0, [sp, #8]
    //APP
.Ltmp1:
    ldaxr    w8, [x0]
    eor    w9, w8, w8, ror #16
    cbnz    w9, .Ltmp2
    add    w8, w8, #16, lsl #12    // =65536
    stxr    w9, w8, [x0]
    cbnz    w9, .Ltmp1
.Ltmp2:
    //NO_APP
    str        w8, [sp]
    str    w9, [sp, #4]
    ldr    w8, [sp, #4]
    cmp        w8, #0          // =0
    cset     w8, ne
    eor    w8, w8, #0x1
    and    w0, w8, #0x1
    add    sp, sp, #16             // =16
    ret
.Lfunc_end0:
    .size    arch_spin_trylock, .Lfunc_end0-arch_spin_trylock


    .ident    "clang version 3.9.0 (trunk 262996) (llvm/trunk 262998)"
    .section    ".note.GNU-stack","", at progbits
dzur:~/tmp> ~/builds/build-llvm/bin/clang -target aarch64-linux-gnu -S foo.c
-O3 -o -
    .text
    .file    "foo.c"
    .globl    arch_spin_trylock
    .p2align    2
    .type    arch_spin_trylock, at function
arch_spin_trylock:                      // @arch_spin_trylock
// BB#0:                                // %entry
    sub    sp, sp, #16             // =16
    //APP
.Ltmp1:
    ldaxr    w8, [x0]
    eor    w9, w8, w8, ror #16
    cbnz    w9, .Ltmp2
    add    w8, w8, #16, lsl #12    // =65536
    stxr    w9, w8, [x0]
    cbnz    w9, .Ltmp1
.Ltmp2:
    //NO_APP
    cmp        w9, #0          // =0
    cset     w0, eq
    str    w8, [sp, #8]
    add    sp, sp, #16             // =16
    ret
.Lfunc_end0:
    .size    arch_spin_trylock, .Lfunc_end0-arch_spin_trylock


    .ident    "clang version 3.9.0 (trunk 262996) (llvm/trunk 262998)"
    .section    ".note.GNU-stack","", at progbits
dzur:~/tmp> cat foo.c
#include <inttypes.h>

#define TICKET_SHIFT 16

typedef struct {
  uint16_t owner;
  uint16_t next;
} __attribute__((aligned(4))) arch_spinlock_t;

int arch_spin_trylock(arch_spinlock_t *lock) {
  unsigned int tmp;
  arch_spinlock_t lockval;

  asm volatile(
      "1:     ldaxr   %w0, %2\n"
      "       eor     %w1, %w0, %w0, ror #16\n"
      "       cbnz    %w1, 2f\n"
      "       add     %w0, %w0, %3\n"
      "       stxr    %w1, %w0, %2\n"
      "       cbnz    %w1, 1b\n"
      "2:"
      : "=&r"(lockval), "=&r"(tmp), "+Q"(*lock)
      : "I"(1 << TICKET_SHIFT)
      : "memory");

  return !tmp;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160309/11db6c49/attachment.html>


More information about the llvm-bugs mailing list