This is an archive of the discontinued LLVM Phabricator instance.

Move pow transformations to sqrt/cbrt to earlier in the compiler pipeline
AbandonedPublic

Authored by masoud.ataei on Sep 22 2021, 1:27 PM.

Details

Reviewers
bmahjour
efriedma
spatel
nemanjai
Group Reviewers
Restricted Project
Summary

All pow(x, a) transformations (where a = 0.5, 0.25, 0.75, 1/3 or 2/3) to sqrt/cbrt calls are done in DAGCombine except pow(x,0.5) --> sqrt(x). The last transformation is implemented LibCallSimplifier::optimizePow.

This patch is proposing to move the rest off the pow(x, a) transformations to LibCallSimplifier::optimizePow. That will move these transformations to earlier step in compiler pipeline.

The motivation for that was this patch https://reviews.llvm.org/D101759 (MASS call transformation for PPC machines). So that we will get these transformations before reaching to MASS scalar pass.

Diff Detail

Event Timeline

masoud.ataei created this revision.Sep 22 2021, 1:27 PM
masoud.ataei requested review of this revision.Sep 22 2021, 1:27 PM
xgupta added a subscriber: xgupta.Sep 23 2021, 4:26 AM

@efriedma is this what you had in mind (based on your comments in https://reviews.llvm.org/D101759)?

Seems like a reasonable approach to me, but it would affect many targets (and the noopt codegen it seems), so I'm not sure if we would need TTI hooks to help us make target dependent decisions here. @spatel @nemanjai any thoughts?

llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
1695

declare SqrtTmp inside the only block that uses it.

llvm/test/CodeGen/AArch64/pow.75.ll
2

Is -O3 really the minimum opt level that would trigger this transformation?

2

Also, these lit tests no longer test codegen, so they should probably be moved elsewhere... under Transforms subdirectories.

Ready for review.

masoud.ataei marked 2 inline comments as done.Oct 6 2021, 2:47 PM
masoud.ataei added inline comments.
llvm/test/CodeGen/AArch64/pow.75.ll
2

-O2 is minimum.

masoud.ataei marked an inline comment as done.Oct 6 2021, 2:47 PM

A gentle reminder for reviewers.

masoud.ataei abandoned this revision.Jan 10 2022, 8:21 AM

This PR is created in support for IBM scalar MASS library pass, but with new approach of handling llvm intrinsic math functions on https://reviews.llvm.org/D101759. There is no need for this PR.

llvm/test/CodeGen/ARM/pow.ll