File: pow-3.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (60 lines) | stat: -rw-r--r-- 2,267 bytes parent folder | download | duplicates (8)
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_test_checks.py
; RUN: opt < %s -disable-simplify-libcalls -instcombine -S | FileCheck %s

declare double @llvm.pow.f64(double, double)
declare double @pow(double, double)

define double @sqrt_libcall(double %x) {
; CHECK-LABEL: @sqrt_libcall(
; CHECK-NEXT:    [[RETVAL:%.*]] = call double @pow(double [[X:%.*]], double 5.000000e-01)
; CHECK-NEXT:    ret double [[RETVAL]]
;
  %retval = call double @pow(double %x, double 0.5)
  ret double %retval
}

define double @sqrt_intrinsic(double %x) {
; CHECK-LABEL: @sqrt_intrinsic(
; CHECK-NEXT:    [[SQRT:%.*]] = call double @llvm.sqrt.f64(double [[X:%.*]])
; CHECK-NEXT:    [[ABS:%.*]] = call double @llvm.fabs.f64(double [[SQRT]])
; CHECK-NEXT:    [[ISINF:%.*]] = fcmp oeq double [[X]], 0xFFF0000000000000
; CHECK-NEXT:    [[TMP1:%.*]] = select i1 [[ISINF]], double 0x7FF0000000000000, double [[ABS]]
; CHECK-NEXT:    ret double [[TMP1]]
;
  %retval = call double @llvm.pow.f64(double %x, double 0.5)
  ret double %retval
}

; Shrinking is disabled too.

define float @shrink_libcall(float %f, float %g) {
; CHECK-LABEL: @shrink_libcall(
; CHECK-NEXT:    [[DF:%.*]] = fpext float [[F:%.*]] to double
; CHECK-NEXT:    [[DG:%.*]] = fpext float [[G:%.*]] to double
; CHECK-NEXT:    [[CALL:%.*]] = call fast double @pow(double [[DF]], double [[DG]])
; CHECK-NEXT:    [[FR:%.*]] = fptrunc double [[CALL]] to float
; CHECK-NEXT:    ret float [[FR]]
;
  %df = fpext float %f to double
  %dg = fpext float %g to double
  %call = call fast double @pow(double %df, double %dg)
  %fr = fptrunc double %call to float
  ret float %fr
}

; Shrinking is disabled for the intrinsic too.

define float @shrink_intrinsic(float %f, float %g) {
; CHECK-LABEL: @shrink_intrinsic(
; CHECK-NEXT:    [[DF:%.*]] = fpext float [[F:%.*]] to double
; CHECK-NEXT:    [[DG:%.*]] = fpext float [[G:%.*]] to double
; CHECK-NEXT:    [[CALL:%.*]] = call fast double @llvm.pow.f64(double [[DF]], double [[DG]])
; CHECK-NEXT:    [[FR:%.*]] = fptrunc double [[CALL]] to float
; CHECK-NEXT:    ret float [[FR]]
;
  %df = fpext float %f to double
  %dg = fpext float %g to double
  %call = call fast double @llvm.pow.f64(double %df, double %dg)
  %fr = fptrunc double %call to float
  ret float %fr
}