[ConstantFolding] Fix 'undef' folding for @llvm.[us]{add,sub}.with.overflow ops ...
authorRoman Lebedev <lebedev.ri@gmail.com>
Sun, 1 Sep 2019 11:56:52 +0000 (11:56 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Sun, 1 Sep 2019 11:56:52 +0000 (11:56 +0000)
commitff21e3f055adf52972c9ead61452ccce25dc677b
tree6b764f13f7c3e49db11bd474193de73b02ebbe74
parent8469a39af3d3db83cf87803b1ea56e22cb522445
[ConstantFolding] Fix 'undef' folding for @llvm.[us]{add,sub}.with.overflow ops (PR43188)

As we have already established/fixed in
  https://bugs.llvm.org/show_bug.cgi?id=42209
  https://reviews.llvm.org/D63065
  https://reviews.llvm.org/rL363522
the InstSimplify handling for @llvm.with.overflow ops with undefs
is correct. Therefore if ConstantFolding produces different results,
then it is wrong.

This duplication of code hints at the need for some refactoring,
but for now address the brokenness of ConstantFolding by
copying the known-good handling from rL363522.

Fixes https://bugs.llvm.org/show_bug.cgi?id=43188

llvm-svn: 370608
llvm/lib/Analysis/ConstantFolding.cpp
llvm/test/Transforms/ConstProp/overflow-ops.ll