xref: /aosp_15_r20/external/llvm/test/Transforms/InstCombine/fold-sqrt-sqrtf.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -instcombine -S -disable-simplify-libcalls < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; rdar://10466410
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker; Instcombine tries to fold (fptrunc (sqrt (fpext x))) -> (sqrtf x), but this
5*9880d681SAndroid Build Coastguard Worker; shouldn't fold when sqrtf isn't available.
6*9880d681SAndroid Build Coastguard Workerdefine float @foo(float %f) uwtable ssp {
7*9880d681SAndroid Build Coastguard Workerentry:
8*9880d681SAndroid Build Coastguard Worker; CHECK: %conv = fpext float %f to double
9*9880d681SAndroid Build Coastguard Worker; CHECK: %call = tail call double @sqrt(double %conv)
10*9880d681SAndroid Build Coastguard Worker; CHECK: %conv1 = fptrunc double %call to float
11*9880d681SAndroid Build Coastguard Worker  %conv = fpext float %f to double
12*9880d681SAndroid Build Coastguard Worker  %call = tail call double @sqrt(double %conv)
13*9880d681SAndroid Build Coastguard Worker  %conv1 = fptrunc double %call to float
14*9880d681SAndroid Build Coastguard Worker  ret float %conv1
15*9880d681SAndroid Build Coastguard Worker}
16*9880d681SAndroid Build Coastguard Worker
17*9880d681SAndroid Build Coastguard Workerdeclare double @sqrt(double)
18