1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -mtriple=amdgcn-amd-amdhsa -instcombine -S | FileCheck %s
3
4; Simplify to +0.0.
5define float @test_zero(float %x) {
6; CHECK-LABEL: @test_zero(
7; CHECK-NEXT:    ret float 0.000000e+00
8;
9  %call = call float @llvm.amdgcn.fmul.legacy(float %x, float 0.0)
10  ret float %call
11}
12
13; Simplify to +0.0.
14define float @test_negzero(float %y) {
15; CHECK-LABEL: @test_negzero(
16; CHECK-NEXT:    ret float 0.000000e+00
17;
18  %call = call float @llvm.amdgcn.fmul.legacy(float -0.0, float %y)
19  ret float %call
20}
21
22; Combine to fmul because the constant is finite and non-zero.
23define float @test_const(float %x) {
24; CHECK-LABEL: @test_const(
25; CHECK-NEXT:    [[CALL:%.*]] = fmul float [[X:%.*]], 9.950000e+01
26; CHECK-NEXT:    ret float [[CALL]]
27;
28  %call = call float @llvm.amdgcn.fmul.legacy(float %x, float 99.5)
29  ret float %call
30}
31
32; Combine to fmul because the constant is finite and non-zero, preserving fmf.
33define float @test_const_fmf(float %x) {
34; CHECK-LABEL: @test_const_fmf(
35; CHECK-NEXT:    [[CALL:%.*]] = fmul contract float [[X:%.*]], 9.950000e+01
36; CHECK-NEXT:    ret float [[CALL]]
37;
38  %call = call contract float @llvm.amdgcn.fmul.legacy(float %x, float 99.5)
39  ret float %call
40}
41
42; Combine to fmul because neither argument can be infinity or NaN.
43define float @test_finite(i32 %x, i32 %y) {
44; CHECK-LABEL: @test_finite(
45; CHECK-NEXT:    [[XF:%.*]] = sitofp i32 [[X:%.*]] to float
46; CHECK-NEXT:    [[YF:%.*]] = sitofp i32 [[Y:%.*]] to float
47; CHECK-NEXT:    [[CALL:%.*]] = fmul float [[XF]], [[YF]]
48; CHECK-NEXT:    ret float [[CALL]]
49;
50  %xf = sitofp i32 %x to float
51  %yf = sitofp i32 %y to float
52  %call = call float @llvm.amdgcn.fmul.legacy(float %xf, float %yf)
53  ret float %call
54}
55
56declare float @llvm.amdgcn.fmul.legacy(float, float)
57