File: constant-fold-math.ll

package info (click to toggle)
llvm-toolchain-6.0 1:6.0-1~bpo9+1
  • links: PTS, VCS
  • area: main
  • in suites: stretch-backports
  • size: 594,652 kB
  • sloc: cpp: 3,044,500; ansic: 595,051; asm: 271,890; python: 128,923; objc: 106,554; sh: 21,854; lisp: 10,191; pascal: 6,094; ml: 5,544; perl: 5,265; makefile: 2,214; cs: 2,027; xml: 686; php: 212; csh: 117
file content (66 lines) | stat: -rw-r--r-- 2,143 bytes parent folder | download | duplicates (17)
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
61
62
63
64
65
66
; RUN: opt -S -instcombine < %s | FileCheck %s

declare float @llvm.fma.f32(float, float, float) #0
declare float @llvm.fmuladd.f32(float, float, float) #0
declare <4 x float> @llvm.fma.v4f32(<4 x float>, <4 x float>, <4 x float>) #0

declare double @llvm.fma.f64(double, double, double) #0
declare double @llvm.fmuladd.f64(double, double, double) #0

declare double @llvm.sqrt.f64(double) #0


; CHECK-LABEL: @constant_fold_fma_f32
; CHECK-NEXT: ret float 6.000000e+00
define float @constant_fold_fma_f32() #0 {
  %x = call float @llvm.fma.f32(float 1.0, float 2.0, float 4.0) #0
  ret float %x
}

; CHECK-LABEL: @constant_fold_fma_v4f32
; CHECK-NEXT: ret <4 x float> <float 1.200000e+01, float 1.400000e+01, float 1.600000e+01, float 1.800000e+01>
define <4 x float> @constant_fold_fma_v4f32() #0 {
  %x = call <4 x float> @llvm.fma.v4f32(<4 x float> <float 1.0, float 2.0, float 3.0, float 4.0>, <4 x float> <float 2.0, float 2.0, float 2.0, float 2.0>, <4 x float> <float 10.0, float 10.0, float 10.0, float 10.0>)
  ret <4 x float> %x
}

; CHECK-LABEL: @constant_fold_fmuladd_f32
; CHECK-NEXT: ret float 6.000000e+00
define float @constant_fold_fmuladd_f32() #0 {
  %x = call float @llvm.fmuladd.f32(float 1.0, float 2.0, float 4.0) #0
  ret float %x
}

; CHECK-LABEL: @constant_fold_fma_f64
; CHECK-NEXT: ret double 6.000000e+00
define double @constant_fold_fma_f64() #0 {
  %x = call double @llvm.fma.f64(double 1.0, double 2.0, double 4.0) #0
  ret double %x
}

; CHECK-LABEL: @constant_fold_fmuladd_f64
; CHECK-NEXT: ret double 6.000000e+00
define double @constant_fold_fmuladd_f64() #0 {
  %x = call double @llvm.fmuladd.f64(double 1.0, double 2.0, double 4.0) #0
  ret double %x
}

; PR32177

; CHECK-LABEL: @constant_fold_frem_f32
; CHECK-NEXT: ret float 0x41A61B2000000000
define float @constant_fold_frem_f32() #0 {
  %x = frem float 0x43cbfcd960000000, 0xc1e2b34a00000000
  ret float %x
}

; PR3316

; CHECK-LABEL: @constant_fold_frem_f64
; CHECK-NEXT: ret double 0.000000e+00
define double @constant_fold_frem_f64() {
  %x = frem double 0x43E0000000000000, 1.000000e+00
  ret double %x
}

attributes #0 = { nounwind readnone }