1; RUN: opt -S -instcombine < %s | FileCheck %s
2
3declare float @llvm.copysign.f32(float, float) #0
4declare double @llvm.copysign.f64(double, double) #0
5
6; CHECK-LABEL: @constant_fold_copysign_f32_01
7; CHECK-NEXT: ret float -1.000000e+00
8define float @constant_fold_copysign_f32_01() #0 {
9  %x = call float @llvm.copysign.f32(float 1.0, float -2.0) #0
10  ret float %x
11}
12
13; CHECK-LABEL: @constant_fold_copysign_f32_02
14; CHECK-NEXT: ret float 2.000000e+00
15define float @constant_fold_copysign_f32_02() #0 {
16  %x = call float @llvm.copysign.f32(float -2.0, float 1.0) #0
17  ret float %x
18}
19
20; CHECK-LABEL: @constant_fold_copysign_f32_03
21; CHECK-NEXT: ret float -2.000000e+00
22define float @constant_fold_copysign_f32_03() #0 {
23  %x = call float @llvm.copysign.f32(float -2.0, float -1.0) #0
24  ret float %x
25}
26
27; CHECK-LABEL: @constant_fold_copysign_f64_01
28; CHECK-NEXT: ret double -1.000000e+00
29define double @constant_fold_copysign_f64_01() #0 {
30  %x = call double @llvm.copysign.f64(double 1.0, double -2.0) #0
31  ret double %x
32}
33
34; CHECK-LABEL: @constant_fold_copysign_f64_02
35; CHECK-NEXT: ret double 1.000000e+00
36define double @constant_fold_copysign_f64_02() #0 {
37  %x = call double @llvm.copysign.f64(double -1.0, double 2.0) #0
38  ret double %x
39}
40
41; CHECK-LABEL: @constant_fold_copysign_f64_03
42; CHECK-NEXT: ret double -1.000000e+00
43define double @constant_fold_copysign_f64_03() #0 {
44  %x = call double @llvm.copysign.f64(double -1.0, double -2.0) #0
45  ret double %x
46}
47
48
49attributes #0 = { nounwind readnone }
50