[gcc r17-3820] fold-const-call: Explain singleton sNaN handling [PR127039]

Kyrylo Tkachov ktkachov@gcc.gnu.org
Tue Sep 1 15:09:07 GMT 2026


https://gcc.gnu.org/g:b74153cc071f4bbedb76f2b72800b2c9467ce996

commit r17-3820-gb74153cc071f4bbedb76f2b72800b2c9467ce996
Author: Kyrylo Tkachov <ktkachov@nvidia.com>
Date:   Fri Aug 28 17:38:57 2026 +0200

    fold-const-call: Explain singleton sNaN handling [PR127039]
    
    Explain why singleton sNaN encodings use the exact element-count fallback.
    
    gcc/ChangeLog:
    
            PR tree-optimization/127039
            * fold-const-call.cc (fold_const_reduction): Explain the handling of
            singleton sNaN encodings.
    
    Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>

Diff:
---
 gcc/fold-const-call.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/fold-const-call.cc b/gcc/fold-const-call.cc
index 10d5f55eae4e..94841e8fb65c 100644
--- a/gcc/fold-const-call.cc
+++ b/gcc/fold-const-call.cc
@@ -631,6 +631,9 @@ fold_const_reduction (tree type, tree arg, tree_code code)
 		       || code == BIT_IOR_EXPR);
 
   unsigned HOST_WIDE_INT nelts = vector_cst_encoded_nelts (arg);
+  /* Fall back to the exact element count for singleton sNaN encodings, since
+     a known single-element vector performs no operation and so cannot raise an
+     exception.  */
   bool singleton_snan_p
     = (nelts == 1
 	&& tree_expr_maybe_signaling_nan_p (VECTOR_CST_ELT (arg, 0)));


More information about the Gcc-cvs mailing list