blob: 157c04cc56121669e947e52310123b0235b85a6d [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64_lfi | FileCheck %s
; LFI cannot sandbox a bit test of memory with a register bit offset, so this
; uses a cmpxchg loop instead of lock btsq %reg, (mem).
define i64 @or_shl1(ptr %p, i64 %c) {
; CHECK-LABEL: or_shl1:
; CHECK: # %bb.0:
; CHECK-NEXT: movq %rsi, %rcx
; CHECK-NEXT: movl $1, %edx
; CHECK-NEXT: # kill: def $cl killed $cl killed $rcx
; CHECK-NEXT: shlq %cl, %rdx
; CHECK-NEXT: movq (%rdi), %rax
; CHECK-NEXT: .p2align 4
; CHECK-NEXT: .LBB0_1: # %atomicrmw.start
; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
; CHECK-NEXT: movq %rax, %rcx
; CHECK-NEXT: orq %rdx, %rcx
; CHECK-NEXT: lock cmpxchgq %rcx, (%rdi)
; CHECK-NEXT: jne .LBB0_1
; CHECK-NEXT: # %bb.2: # %atomicrmw.end
; CHECK-NEXT: andq %rdx, %rax
; CHECK-NEXT: retq
%shl = shl i64 1, %c
%old = atomicrmw or ptr %p, i64 %shl monotonic
%and = and i64 %old, %shl
ret i64 %and
}
; A bit test with an immediate bit offset is still used.
define i64 @or_const(ptr %p) {
; CHECK-LABEL: or_const:
; CHECK: # %bb.0:
; CHECK-NEXT: xorl %eax, %eax
; CHECK-NEXT: lock btsq $4, (%rdi)
; CHECK-NEXT: setb %al
; CHECK-NEXT: shll $4, %eax
; CHECK-NEXT: retq
%old = atomicrmw or ptr %p, i64 16 monotonic
%and = and i64 %old, 16
ret i64 %and
}