[FLANG] Change loop versioning to use shift instead of divide
authorMats Petersson <mats.petersson@arm.com>
Thu, 1 Jun 2023 10:39:26 +0000 (11:39 +0100)
committerMats Petersson <mats.petersson@arm.com>
Thu, 1 Jun 2023 18:29:57 +0000 (19:29 +0100)
commitb812932b3582752eb45240044be8ac1a9df4759f
tree68727560133da08cc8c1db8f34d4d7040363d691
parent8dc13957cb1752b6a90e299d016e09bb98b0df54
[FLANG] Change loop versioning to use shift instead of divide

Despite me being convinced that the use of divide didn't produce any
divide instructions, it does in fact add more instructions than using
a plain shift operation.

This patch simply changes the divide to a shift right, with an
assert to check that the "divisor" is a power of two.

Reviewed By: kiranchandramohan, tblah

Differential Revision: https://reviews.llvm.org/D151880
flang/lib/Optimizer/Transforms/LoopVersioning.cpp
flang/test/Transforms/loop-versioning.fir