We already have pow(x, y) * pow(x, z) -> pow(x, y + z) transformation, but we are missing same transformation for powi (power is integer).
Requires reassoc.
Paths
| Differential D109954
[InstCombine] powi(x, y) * powi(x, z) -> powi(x, y + z) ClosedPublic Authored by xbolva00 on Sep 17 2021, 12:50 AM.
Details Summary We already have pow(x, y) * pow(x, z) -> pow(x, y + z) transformation, but we are missing same transformation for powi (power is integer). Requires reassoc.
Diff Detail Event TimelineComment Actions Pre-commit tests please, so it's easier to see transforms vs. negative tests. I'd vary at least one positive test to have extra FMF (eg, "fast"), so we know everything is transferred as expected. And we need at least one more test like this: define double @different_types_powi(double %x, i32 %y, i64 %z) { %p1 = tail call double @llvm.powi.f64.i32(double %x, i32 %y) %p2 = tail call double @llvm.powi.f64.i64(double %x, i64 %z) %mul = fmul reassoc double %p2, %p1 ret double %mul } Comment Actions
Thanks!
gotcha, added type check. Comment Actions LGTM
This revision is now accepted and ready to land.Sep 19 2021, 7:09 AM Closed by commit rGc0fdfc9af233: [InstCombine] powi(x, y) * powi(x, z) -> powi(x, y + z) (authored by xbolva00). · Explain WhySep 21 2021, 9:20 AM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 373162 llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
llvm/test/Transforms/InstCombine/powi.ll
|
I don't think this actually tests the pattern that we want. We just swapped the names of y and z, so it's functionally the same as the previous test. Just commute the fmul operands instead?