1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -mtriple=amdgcn-amd-amdhsa -instcombine -S | FileCheck %s
5 define float @test_zero(float %x) {
6 ; CHECK-LABEL: @test_zero(
7 ; CHECK-NEXT: ret float 0.000000e+00
9 %call = call float @llvm.amdgcn.fmul.legacy(float %x, float 0.0)
14 define float @test_negzero(float %y) {
15 ; CHECK-LABEL: @test_negzero(
16 ; CHECK-NEXT: ret float 0.000000e+00
18 %call = call float @llvm.amdgcn.fmul.legacy(float -0.0, float %y)
22 ; Combine to fmul because the constant is finite and non-zero.
23 define 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]]
28 %call = call float @llvm.amdgcn.fmul.legacy(float %x, float 99.5)
32 ; Combine to fmul because the constant is finite and non-zero, preserving fmf.
33 define 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]]
38 %call = call contract float @llvm.amdgcn.fmul.legacy(float %x, float 99.5)
42 ; Combine to fmul because neither argument can be infinity or NaN.
43 define 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]]
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)
56 declare float @llvm.amdgcn.fmul.legacy(float, float)