[InstCombine] fold udiv with common factor from muls with nuw
authorSanjay Patel <spatel@rotateright.com>
Thu, 26 Jul 2018 19:22:41 +0000 (19:22 +0000)
committerSanjay Patel <spatel@rotateright.com>
Thu, 26 Jul 2018 19:22:41 +0000 (19:22 +0000)
commit6d6eab66e0f76c8bb908492dcc863308b66f7771
tree833b00bb921003640a20c2665cc308eece4338ec
parent10c9e0e0d8c6f9651e9b2bb85518dc9302245f53
[InstCombine] fold udiv with common factor from muls with nuw

Unfortunately, sdiv isn't as simple because of UB due to overflow.

This fold is mentioned in PR38239:
https://bugs.llvm.org/show_bug.cgi?id=38239

llvm-svn: 338059
llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
llvm/test/Transforms/InstCombine/div.ll