[CostModel] Express cost(urem) as cost(div+mul+sub) when set to Expand.
authorSander de Smalen <sander.desmalen@arm.com>
Wed, 7 Jul 2021 12:19:59 +0000 (13:19 +0100)
committerSander de Smalen <sander.desmalen@arm.com>
Wed, 7 Jul 2021 13:40:28 +0000 (14:40 +0100)
commit97215fe3f4d51977d7f4bbc65249ccfc0212a8ae
treefc75238f29e9fc01e2fd2d42a2d51c1dc8bdf43c
parentd6595278291425804d05985652831d2781abdf06
[CostModel] Express cost(urem) as cost(div+mul+sub) when set to Expand.

The Legalizer expands the operations of urem/srem into a div+mul+sub or divrem
when those are legal/custom. This patch changes the cost-model to reflect that
cost.

Since there is no 'divrem' Instruction in LLVM IR, the cost of divrem
is assumed to be the same as div+mul+sub since the three operations will
need to be executed at runtime regardless.

Patch co-authored by David Sherwood (@david-arm)

Reviewed By: RKSimon, paulwalker-arm

Differential Revision: https://reviews.llvm.org/D103799
llvm/include/llvm/CodeGen/BasicTTIImpl.h
llvm/test/Analysis/CostModel/AArch64/sve-remainder.ll
llvm/test/Analysis/CostModel/ARM/divrem.ll
llvm/test/Analysis/CostModel/X86/rem.ll