diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index d8497fc9be7..3543f0980b8 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -1032,10 +1032,7 @@ fold_using_range::range_of_builtin_int_call (irange &r, gcall *call, if (tmp.get_signbit ().varying_p ()) return false; if (tmp.get_signbit ().yes_p ()) - { - tree one = build_one_cst (type); - r.set (one, one); - } + r.set_nonzero (type); else r.set_zero (type); return true; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp-float-signbit-2.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp-float-signbit-2.c new file mode 100644 index 00000000000..954c7ebd4f8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp-float-signbit-2.c @@ -0,0 +1,24 @@ +// { dg-do compile } +// { dg-options "-O2 -fdump-tree-evrp" } + +// Test that the only thing we know about the signbit about negative number is +// that it's not 0. + +void link_error (); + +int num; + +void func(float x) +{ + if (x < -5.0) + { + num = __builtin_signbit (x); + + // We may not know the exact signbit, but we know it's not 0. + if (!__builtin_signbit (x)) + link_error (); + } +} + +// { dg-final { scan-tree-dump-not "num = \[-0-9\];" "evrp" } } +// { dg-final { scan-tree-dump-not "link_error" "evrp" } }