]> git.ipfire.org Git - thirdparty/gcc.git/commit
ranger: Add support for float <-> float casts [PR120231]
authorJakub Jelinek <jakub@redhat.com>
Wed, 4 Jun 2025 15:21:51 +0000 (17:21 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 4 Jun 2025 15:22:37 +0000 (17:22 +0200)
commitb7960a3f966a0f87888de0fc588999d026918449
tree440eae63a4ddbae9178eedf46d65ca1f5a57aa40
parent3cfa53aa95a19c3b5fc711ad4d9f39ec9b8e7c3f
ranger: Add support for float <-> float casts [PR120231]

I've noticed we don't even support say float -> double and other
scalar floating point to scalar floating point conversions in the
ranger, we just end up with VARYING for those.

The following patch attempts to fix that.
The reverse cast case uses float_binary_op_range_finish e.g. because
if the result isn't infinite, then the source couldn't be infinite
either even if the reverse fold_range would suggest that.
And special cases the case of guaranteed widening cast (where
we have assurance that all the source type values are exactly
representable in the destination type; using ieee_bits for that).

2025-06-04  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/120231
* range-op-mixed.h (operator_cast::fold_range): Add overload
with 3 {,const} frange & operands.  Change parameter names and
add final override keywords for float <-> integer cast overloads.
(operator_cast::op1_range): Likewise.
* range-op-float.cc (operator_cast::fold_range): New overload
with 3 {,const} frange & operands.
(operator_cast::op1_range): Likewise.

* gcc.dg/tree-ssa/pr120231-1.c: New test.
gcc/range-op-float.cc
gcc/range-op-mixed.h
gcc/testsuite/gcc.dg/tree-ssa/pr120231-1.c [new file with mode: 0644]