99 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3 4declare float @llvm.minimum.f32(float %Val0, float %Val1)5declare float @llvm.maximum.f32(float %Val0, float %Val1)6declare <4 x float> @llvm.minimum.v4f32(<4 x float> %Val0, <4 x float> %Val1)7declare <4 x float> @llvm.maximum.v4f32(<4 x float> %Val0, <4 x float> %Val1)8 9define float @test(float %a, float %b) {10; CHECK-LABEL: @test(11; CHECK-NEXT: entry:12; CHECK-NEXT: [[RES:%.*]] = fadd float [[A:%.*]], [[B:%.*]]13; CHECK-NEXT: ret float [[RES]]14;15entry: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, %max19 ret float %res20}21 22define float @test_comm1(float %a, float %b) {23; CHECK-LABEL: @test_comm1(24; CHECK-NEXT: entry:25; CHECK-NEXT: [[RES:%.*]] = fadd float [[A:%.*]], [[B:%.*]]26; CHECK-NEXT: ret float [[RES]]27;28entry: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, %min32 ret float %res33}34 35define float @test_comm2(float %a, float %b) {36; CHECK-LABEL: @test_comm2(37; CHECK-NEXT: entry:38; CHECK-NEXT: [[RES:%.*]] = fadd float [[B:%.*]], [[A:%.*]]39; CHECK-NEXT: ret float [[RES]]40;41entry: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, %max45 ret float %res46}47 48define float @test_comm3(float %a, float %b) {49; CHECK-LABEL: @test_comm3(50; CHECK-NEXT: entry:51; CHECK-NEXT: [[RES:%.*]] = fadd float [[B:%.*]], [[A:%.*]]52; CHECK-NEXT: ret float [[RES]]53;54entry: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, %min58 ret float %res59}60 61define <4 x float> @test_vect(<4 x float> %a, <4 x float> %b) {62; CHECK-LABEL: @test_vect(63; CHECK-NEXT: entry:64; CHECK-NEXT: [[RES:%.*]] = fadd <4 x float> [[B:%.*]], [[A:%.*]]65; CHECK-NEXT: ret <4 x float> [[RES]]66;67entry: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, %max71 ret <4 x float> %res72}73 74define float @test_flags(float %a, float %b) {75; CHECK-LABEL: @test_flags(76; CHECK-NEXT: entry:77; CHECK-NEXT: [[RES:%.*]] = fadd fast float [[A:%.*]], [[B:%.*]]78; CHECK-NEXT: ret float [[RES]]79;80entry: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, %max84 ret float %res85}86 87define float @test_flags2(float %a, float %b) {88; CHECK-LABEL: @test_flags2(89; CHECK-NEXT: entry:90; CHECK-NEXT: [[RES:%.*]] = fadd reassoc nsz arcp contract afn float [[A:%.*]], [[B:%.*]]91; CHECK-NEXT: ret float [[RES]]92;93entry: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, %max97 ret float %res98}99