[InstCombine] fold flooring sdiv by power-of-2 to ashr
authorSanjay Patel <spatel@rotateright.com>
Sun, 18 Dec 2022 13:13:21 +0000 (08:13 -0500)
committerSanjay Patel <spatel@rotateright.com>
Sun, 18 Dec 2022 13:17:07 +0000 (08:17 -0500)
commit86b4a2355e73ff37a785aac7462d8e63e3033079
tree420a9cbc98d37c5061207ab4240594d419cbd7a0
parent3c7d059f453705b95a902eb43df8b5c76859ab27
[InstCombine] fold flooring sdiv by power-of-2 to ashr

It's a bigger match than usual, but I have not found any
sub-patterns that reduce:
(X / DivC) + sext ((X & (SMin | (DivC - 1)) >u SMin) --> X >>s log2(DivC)

https://alive2.llvm.org/ce/z/MJzlhl

Fixes issue #55741
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/test/Transforms/InstCombine/add.ll