llvm-project
llvm-project copied to clipboard
[InstCombine] scalbn should be canonicalized to ldexp
https://godbolt.org/z/z4Maf734d
double foo(double a, int b){
return __builtin_scalbn(a,b);
}
double bar(double a, int b){
return __builtin_ldexp(a,b);
}
foo(double, int):
jmp scalbn@PLT
bar(double, int):
vcvtsi2sd xmm1, xmm15, edi
vscalefsd xmm0, xmm0, xmm1
ret
foo(double, int):
b scalbn
bar(double, int):
sxtw x8, w0
ptrue p0.d
fmov d1, x8
fscale z0.d, p0/m, z0.d, z1.d
ret
For many backends, scalbn and ldexp are equivalent, but ldexp can be inlined while scalbn cannot. best to uniformly canonicalize them to ldexp in InstCombine.
Hi, I'd be interested in working on this. Could you assign it to me?