[PATCH] D37121: [DivRemHoist] add a pass to move div/rem pairs into the same block (PR31028)
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 24 14:54:52 PDT 2017
spatel created this revision.
Herald added subscribers: kristof.beyls, mgorny, mcrosier, mehdi_amini, aemerson.
This is intended to be the same functionality as https://reviews.llvm.org/D31037 (EarlyCSE) but implemented as an independent pass, so there's no stretching of scope and feature creep for an existing pass. I also proposed a weaker version of this for SimplifyCFG in https://reviews.llvm.org/D30910. And I initially had almost this same functionality as another lump of CGP in the motivating example of PR31028 ( https://bugs.llvm.org/show_bug.cgi?id=31028 ). It's been a long road. :)
The advantage of positioning this ahead of SimplifyCFG / InstCombine in the pass pipeline is that we'll reduce the positive test cases to a single block:
%rem = urem i8 %a, %b
%div = udiv i8 %a, %b
%cmp = icmp eq i8 %div, 42
%sel = select i1 %cmp, i8 %rem, i8 3
ret i8 %sel
...and that can lead to better codegen even for targets that don't have a joint divrem instruction. https://reviews.llvm.org/D30910 has an AArch64 example of that.
https://reviews.llvm.org/D37121
Files:
include/llvm/InitializePasses.h
include/llvm/Transforms/Scalar.h
include/llvm/Transforms/Scalar/DivRemHoist.h
lib/Passes/PassBuilder.cpp
lib/Passes/PassRegistry.def
lib/Transforms/IPO/PassManagerBuilder.cpp
lib/Transforms/Scalar/CMakeLists.txt
lib/Transforms/Scalar/DivRemHoist.cpp
lib/Transforms/Scalar/Scalar.cpp
test/Transforms/DivRemHoist/div-rem-pairs.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37121.112612.patch
Type: text/x-patch
Size: 17636 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170824/6956d96b/attachment.bin>
More information about the llvm-commits
mailing list