Simplify pow(2.0, itofp(y)) to ldexp(1.0, y).
Details
Diff Detail
Event Timeline
Does this require fast math due to rounding in the sitofp conversion? Off the top of my head, probably it doesn't matter because those cases would produce zero or infinity anyway, but it's worth explaining in the code.
I think there is a general case... pow(powOf2, itofp(y)) to ldexp(1.0, log2(powOf2) * y).
My fast patch from yday.. https://pastebin.com/ETZpNby5 line 1350.
llvm/test/Transforms/InstCombine/pow_fp_int.ll | ||
---|---|---|
292 | Avoid this change. |
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | ||
---|---|---|
1332 | There is one "emit ldexp" old code in SLC which could use emitBinaryFloatFnCall. |
Since exp2(itofp(x) is similarly simplified into ldexp(1.0, x) without accounting for any relaxation, methinks that this simplification should be fine too. Will note this.
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | ||
---|---|---|
1332 | Indeed, there are other places that could use emitBinaryFloatFnCall(). |
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | ||
---|---|---|
1327 | Can we extract this “fits in int” code to helper function? optimize exp2 checks it too, and that fold could use it too... and my powi fold too (Optional) |
Can we extract this “fits in int” code to helper function? optimize exp2 checks it too, and that fold could use it too... and my powi fold too
(Optional)