[InstCombine] Without infinites, fold (C / X) < 0.0 --> (X < 0)
authorSanjay Patel <spatel@rotateright.com>
Thu, 27 Sep 2018 15:59:24 +0000 (15:59 +0000)
committerSanjay Patel <spatel@rotateright.com>
Thu, 27 Sep 2018 15:59:24 +0000 (15:59 +0000)
commitc3f50ff92e0f37484d3bef1d580ab0ceb54db733
treec0fa26af0ef94e5af5623ad7dbbfc1d0cbdb17aa
parentc2a88ea64e154d44f0a8da44bf84b9acac52066b
[InstCombine] Without infinites, fold (C / X) < 0.0 --> (X < 0)

When C is not zero and infinites are not allowed (C / X) > 0 is a sign
test. Depending on the sign of C, the predicate must be swapped.

E.g.:
  foo(double X) {
    if ((-2.0 / X) <= 0) ...
  }
 =>
  foo(double X) {
    if (X >= 0) ...
  }

Patch by: @marels (Martin Elshuber)

Differential Revision: https://reviews.llvm.org/D51942

llvm-svn: 343228
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/fcmp.ll