Page MenuHomePhabricator

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

Authored by masoud.ataei on Wed, Sep 22, 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.Wed, Sep 22, 1:27 PM
masoud.ataei requested review of this revision.Wed, Sep 22, 1:27 PM
xgupta added a subscriber: xgupta.Thu, Sep 23, 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.Wed, Oct 6, 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.Wed, Oct 6, 2:47 PM

A gentle reminder for reviewers.