AMDGPU: Add option to expand 64-bit integer division in IR
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Sun, 19 Jan 2020 03:41:36 +0000 (22:41 -0500)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 14 Feb 2020 19:16:08 +0000 (11:16 -0800)
commit34d9a16e54becbea4c790b19804d35453018a53f
tree81f5401f54b3d1e58b84c75d749f794e13b79be8
parent391cc4dd41db934081c37ee523cb2149bf0e3a41
AMDGPU: Add option to expand 64-bit integer division in IR

I didn't realize we were already expanding 24/32-bit division here
already. Use the available IntegerDivision utilities. This uses loops,
so produces significantly smaller code than the inline DAG expansion.

This now requires width reductions of 64-bit divisions before
introducing the expanded loops.

This helps work around missing legalization in GlobalISel for
division, which are the only remaining core instructions that didn't
work at all.

I think this is plausibly a better implementation than exists in the
DAG, although turning it on by default misses out on the constant
value optimizations and also needs benchmarking.
llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
llvm/test/CodeGen/AMDGPU/amdgpu-codegenprepare-idiv.ll
llvm/test/CodeGen/AMDGPU/sdiv64.ll
llvm/test/CodeGen/AMDGPU/srem64.ll
llvm/test/CodeGen/AMDGPU/udiv64.ll
llvm/test/CodeGen/AMDGPU/urem64.ll