llvm-project/llvm/test/Transforms/InstCombine/fpextend.ll

89 lines
2.8 KiB
LLVM
Raw Normal View History

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
define float @test(float %x) nounwind {
; CHECK-LABEL: @test(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP34:%.*]] = fadd float [[X:%.*]], 0.000000e+00
; CHECK-NEXT: ret float [[TMP34]]
;
entry:
%tmp1 = fpext float %x to double
%tmp3 = fadd double %tmp1, 0.000000e+00
%tmp34 = fptrunc double %tmp3 to float
ret float %tmp34
}
define float @test2(float %x, float %y) nounwind {
; CHECK-LABEL: @test2(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP56:%.*]] = fmul float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: ret float [[TMP56]]
;
entry:
%tmp1 = fpext float %x to double
%tmp23 = fpext float %y to double
%tmp5 = fmul double %tmp1, %tmp23
%tmp56 = fptrunc double %tmp5 to float
ret float %tmp56
}
define float @test3(float %x, float %y) nounwind {
; CHECK-LABEL: @test3(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP56:%.*]] = fdiv float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: ret float [[TMP56]]
;
entry:
%tmp1 = fpext float %x to double
%tmp23 = fpext float %y to double
%tmp5 = fdiv double %tmp1, %tmp23
%tmp56 = fptrunc double %tmp5 to float
ret float %tmp56
}
define float @test4(float %x) nounwind {
; CHECK-LABEL: @test4(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP34:%.*]] = fsub float -0.000000e+00, [[X:%.*]]
; CHECK-NEXT: ret float [[TMP34]]
;
entry:
%tmp1 = fpext float %x to double
%tmp2 = fsub double -0.000000e+00, %tmp1
%tmp34 = fptrunc double %tmp2 to float
ret float %tmp34
}
; Test with vector splat constant
define <2 x float> @test5(<2 x float> %x) nounwind {
; CHECK-LABEL: @test5(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP1:%.*]] = fpext <2 x float> [[X:%.*]] to <2 x double>
; CHECK-NEXT: [[TMP3:%.*]] = fadd <2 x double> [[TMP1]], zeroinitializer
; CHECK-NEXT: [[TMP34:%.*]] = fptrunc <2 x double> [[TMP3]] to <2 x float>
; CHECK-NEXT: ret <2 x float> [[TMP34]]
;
entry:
%tmp1 = fpext <2 x float> %x to <2 x double>
%tmp3 = fadd <2 x double> %tmp1, <double 0.000000e+00, double 0.000000e+00>
%tmp34 = fptrunc <2 x double> %tmp3 to <2 x float>
ret <2 x float> %tmp34
}
; Test with a non-splat constant
define <2 x float> @test6(<2 x float> %x) nounwind {
; CHECK-LABEL: @test6(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP1:%.*]] = fpext <2 x float> [[X:%.*]] to <2 x double>
; CHECK-NEXT: [[TMP3:%.*]] = fadd <2 x double> [[TMP1]], <double 0.000000e+00, double -0.000000e+00>
; CHECK-NEXT: [[TMP34:%.*]] = fptrunc <2 x double> [[TMP3]] to <2 x float>
; CHECK-NEXT: ret <2 x float> [[TMP34]]
;
entry:
%tmp1 = fpext <2 x float> %x to <2 x double>
%tmp3 = fadd <2 x double> %tmp1, <double 0.000000e+00, double -0.000000e+00>
%tmp34 = fptrunc <2 x double> %tmp3 to <2 x float>
ret <2 x float> %tmp34
}