1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
4 declare float @llvm.minimum.f32(float %Val0, float %Val1)
5 declare float @llvm.maximum.f32(float %Val0, float %Val1)
6 declare <4 x float> @llvm.minimum.v4f32(<4 x float> %Val0, <4 x float> %Val1)
7 declare <4 x float> @llvm.maximum.v4f32(<4 x float> %Val0, <4 x float> %Val1)
9 define float @test(float %a, float %b) {
12 ; CHECK-NEXT: [[RES:%.*]] = fadd float [[A:%.*]], [[B:%.*]]
13 ; CHECK-NEXT: ret float [[RES]]
16 %min = call float @llvm.minimum.f32(float %a, float %b)
17 %max = call float @llvm.maximum.f32(float %a, float %b)
18 %res = fadd float %min, %max
22 define float @test_comm1(float %a, float %b) {
23 ; CHECK-LABEL: @test_comm1(
25 ; CHECK-NEXT: [[RES:%.*]] = fadd float [[A:%.*]], [[B:%.*]]
26 ; CHECK-NEXT: ret float [[RES]]
29 %min = call float @llvm.minimum.f32(float %a, float %b)
30 %max = call float @llvm.maximum.f32(float %a, float %b)
31 %res = fadd float %max, %min
35 define float @test_comm2(float %a, float %b) {
36 ; CHECK-LABEL: @test_comm2(
38 ; CHECK-NEXT: [[RES:%.*]] = fadd float [[B:%.*]], [[A:%.*]]
39 ; CHECK-NEXT: ret float [[RES]]
42 %min = call float @llvm.minimum.f32(float %a, float %b)
43 %max = call float @llvm.maximum.f32(float %b, float %a)
44 %res = fadd float %min, %max
48 define float @test_comm3(float %a, float %b) {
49 ; CHECK-LABEL: @test_comm3(
51 ; CHECK-NEXT: [[RES:%.*]] = fadd float [[B:%.*]], [[A:%.*]]
52 ; CHECK-NEXT: ret float [[RES]]
55 %min = call float @llvm.minimum.f32(float %a, float %b)
56 %max = call float @llvm.maximum.f32(float %b, float %a)
57 %res = fadd float %max, %min
61 define <4 x float> @test_vect(<4 x float> %a, <4 x float> %b) {
62 ; CHECK-LABEL: @test_vect(
64 ; CHECK-NEXT: [[RES:%.*]] = fadd <4 x float> [[B:%.*]], [[A:%.*]]
65 ; CHECK-NEXT: ret <4 x float> [[RES]]
68 %min = call <4 x float> @llvm.minimum.v4f32(<4 x float> %a, <4 x float> %b)
69 %max = call <4 x float> @llvm.maximum.v4f32(<4 x float> %b, <4 x float> %a)
70 %res = fadd <4 x float> %min, %max
74 define float @test_flags(float %a, float %b) {
75 ; CHECK-LABEL: @test_flags(
77 ; CHECK-NEXT: [[RES:%.*]] = fadd fast float [[A:%.*]], [[B:%.*]]
78 ; CHECK-NEXT: ret float [[RES]]
81 %min = call float @llvm.minimum.f32(float %a, float %b)
82 %max = call float @llvm.maximum.f32(float %a, float %b)
83 %res = fadd fast float %min, %max
87 define float @test_flags2(float %a, float %b) {
88 ; CHECK-LABEL: @test_flags2(
90 ; CHECK-NEXT: [[RES:%.*]] = fadd reassoc nsz arcp contract afn float [[A:%.*]], [[B:%.*]]
91 ; CHECK-NEXT: ret float [[RES]]
94 %min = call float @llvm.minimum.f32(float %a, float %b)
95 %max = call float @llvm.maximum.f32(float %a, float %b)
96 %res = fadd reassoc ninf nsz arcp contract afn float %min, %max