[SDAG] Expand pow2 mulo using shifts
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 12 Mar 2019 16:57:25 +0000 (16:57 +0000)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 12 Mar 2019 16:57:25 +0000 (16:57 +0000)
commit149bc099f61a81a37751622c1b6d405fddb46204
tree8c94296f40770a4ac8bb7aa156f4326c661e23e2
parent13ecae2f9a56dbf68a4ae9d302d4d53af1703e2b
[SDAG] Expand pow2 mulo using shifts

Expand MULO with constant power of two operand into a shift. The
overflow is checked with (x << shift) >> shift == x, where the right
shift will be logical for umulo and arithmetic for smulo (with
exception for multiplications by signed_min).

Differential Revision: https://reviews.llvm.org/D59041

llvm-svn: 355937
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/ARM/umulo-32.ll
llvm/test/CodeGen/X86/mulo-pow2.ll