[InstSimplify] Don't miscompile `X == 0 ? abs(X) : -abs(X) --> -abs(X)` xform
authorRoman Lebedev <lebedev.ri@gmail.com>
Fri, 18 Dec 2020 17:29:27 +0000 (20:29 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Fri, 18 Dec 2020 18:18:13 +0000 (21:18 +0300)
commite9289dc25f7923abff9ac762bd3f6819c0605f20
treebff0d4a018d12d1bcd6bccc48bee5899d492ff69
parent9b183a1452c7e5091be01661188b7cb04d842a4c
[InstSimplify] Don't miscompile `X == 0 ? abs(X) : -abs(X) --> -abs(X)` xform

The transform wasn't checking that the LHS of the comparison
*is* the `X` in question...
This is the miscompile that was holding up D87188.

Thanks to Dave Green for producing an actionable reproducer!
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/abs_intrinsic.ll