File: fpscr-multi-use.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (60 lines) | stat: -rw-r--r-- 1,923 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc -mtriple=armv7 %s -o - | FileCheck %s
; RUN: llc -mtriple=thumbv7 %s -o - | FileCheck --check-prefix=THUMB %s

declare double @fn()

define void @test(ptr %p, ptr %res) nounwind {
; CHECK-LABEL: test:
; CHECK:       @ %bb.0: @ %entry
; CHECK-NEXT:    push {r4, r5, r11, lr}
; CHECK-NEXT:    vldr d16, [r0]
; CHECK-NEXT:    mov r4, r1
; CHECK-NEXT:    vcmp.f64 d16, #0
; CHECK-NEXT:    vmrs APSR_nzcv, fpscr
; CHECK-NEXT:    mrs r5, apsr
; CHECK-NEXT:    vneg.f64 d17, d16
; CHECK-NEXT:    vmovne.f64 d16, d17
; CHECK-NEXT:    vstr d16, [r1]
; CHECK-NEXT:    bl fn
; CHECK-NEXT:    vmov d16, r0, r1
; CHECK-NEXT:    eor r1, r1, #-2147483648
; CHECK-NEXT:    msr APSR_nzcvq, r5
; CHECK-NEXT:    vmov d17, r0, r1
; CHECK-NEXT:    vmovne.f64 d16, d17
; CHECK-NEXT:    vstr d16, [r4]
; CHECK-NEXT:    pop {r4, r5, r11, pc}
;
; THUMB-LABEL: test:
; THUMB:       @ %bb.0: @ %entry
; THUMB-NEXT:    push {r4, r5, r7, lr}
; THUMB-NEXT:    vldr d16, [r0]
; THUMB-NEXT:    mov r4, r1
; THUMB-NEXT:    vcmp.f64 d16, #0
; THUMB-NEXT:    vmrs APSR_nzcv, fpscr
; THUMB-NEXT:    mrs r5, apsr
; THUMB-NEXT:    vneg.f64 d17, d16
; THUMB-NEXT:    it ne
; THUMB-NEXT:    vmovne.f64 d16, d17
; THUMB-NEXT:    vstr d16, [r1]
; THUMB-NEXT:    bl fn
; THUMB-NEXT:    vmov d16, r0, r1
; THUMB-NEXT:    eor r1, r1, #-2147483648
; THUMB-NEXT:    msr APSR_nzcvq, r5
; THUMB-NEXT:    vmov d17, r0, r1
; THUMB-NEXT:    it ne
; THUMB-NEXT:    vmovne.f64 d16, d17
; THUMB-NEXT:    vstr d16, [r4]
; THUMB-NEXT:    pop {r4, r5, r7, pc}
entry:
  %x = load double, ptr %p
  %cmp = fcmp une double %x, 0.000000e+00
  %nx = fneg double %x
  %sx = select i1 %cmp, double %nx, double %x
  store double %sx, ptr %res
  %y = call double @fn()
  %ny = fneg double %y
  %sy = select i1 %cmp, double %ny, double %y
  store double %sy, ptr %res
  ret void
}