2012-12-30 02:28:40 +01:00
|
|
|
; RUN: opt -S -instcombine < %s | FileCheck %s
|
2010-07-19 10:14:26 +02:00
|
|
|
|
2010-09-07 22:01:38 +02:00
|
|
|
define float @test1(float %x) nounwind readnone ssp {
|
2010-07-19 10:14:26 +02:00
|
|
|
entry:
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test1(
|
2010-07-19 10:14:26 +02:00
|
|
|
; CHECK-NOT: fpext
|
|
|
|
; CHECK-NOT: sqrt(
|
|
|
|
; CHECK: sqrtf(
|
|
|
|
; CHECK-NOT: fptrunc
|
|
|
|
%conv = fpext float %x to double ; <double> [#uses=1]
|
2010-09-07 22:01:38 +02:00
|
|
|
%call = tail call double @sqrt(double %conv) readnone nounwind ; <double> [#uses=1]
|
2010-07-19 10:14:26 +02:00
|
|
|
%conv1 = fptrunc double %call to float ; <float> [#uses=1]
|
|
|
|
; CHECK: ret float
|
|
|
|
ret float %conv1
|
|
|
|
}
|
|
|
|
|
2010-09-07 22:01:38 +02:00
|
|
|
; PR8096
|
|
|
|
define float @test2(float %x) nounwind readnone ssp {
|
|
|
|
entry:
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test2(
|
2010-09-07 22:01:38 +02:00
|
|
|
; CHECK-NOT: fpext
|
|
|
|
; CHECK-NOT: sqrt(
|
|
|
|
; CHECK: sqrtf(
|
|
|
|
; CHECK-NOT: fptrunc
|
|
|
|
%conv = fpext float %x to double ; <double> [#uses=1]
|
|
|
|
%call = tail call double @sqrt(double %conv) nounwind ; <double> [#uses=1]
|
|
|
|
%conv1 = fptrunc double %call to float ; <float> [#uses=1]
|
|
|
|
; CHECK: ret float
|
|
|
|
ret float %conv1
|
|
|
|
}
|
2011-07-13 21:08:16 +02:00
|
|
|
|
|
|
|
; rdar://9763193
|
|
|
|
; Can't fold (fptrunc (sqrt (fpext x))) -> (sqrtf x) since there is another
|
|
|
|
; use of sqrt result.
|
|
|
|
define float @test3(float* %v) nounwind uwtable ssp {
|
|
|
|
entry:
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test3(
|
2011-07-13 21:08:16 +02:00
|
|
|
; CHECK: sqrt(
|
|
|
|
; CHECK-NOT: sqrtf(
|
|
|
|
; CHECK: fptrunc
|
2011-07-13 21:19:44 +02:00
|
|
|
%arrayidx13 = getelementptr inbounds float* %v, i64 2
|
|
|
|
%tmp14 = load float* %arrayidx13
|
|
|
|
%mul18 = fmul float %tmp14, %tmp14
|
|
|
|
%add19 = fadd float undef, %mul18
|
|
|
|
%conv = fpext float %add19 to double
|
|
|
|
%call34 = call double @sqrt(double %conv) readnone
|
2011-07-13 21:08:16 +02:00
|
|
|
%call36 = call i32 (double)* @foo(double %call34) nounwind
|
|
|
|
%conv38 = fptrunc double %call34 to float
|
|
|
|
ret float %conv38
|
|
|
|
}
|
|
|
|
|
|
|
|
declare i32 @foo(double)
|
|
|
|
|
|
|
|
declare double @sqrt(double) readnone
|