aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.cc
diff options
context:
space:
mode:
authorAndrew Pinski <quic_apinski@quicinc.com>2024-03-10 22:17:09 +0000
committerAndrew Pinski <quic_apinski@quicinc.com>2024-03-10 19:58:49 -0700
commit31ce2e993d09dcad1ce139a2848a28de5931056d (patch)
tree7ef01abd7695ec75585f7de6c2d445b152fee5a6 /gcc/fold-const.cc
parent1a4553bc253fc0141e5f41ac15a2320f650c9e7c (diff)
downloadgcc-31ce2e993d09dcad1ce139a2848a28de5931056d.zip
gcc-31ce2e993d09dcad1ce139a2848a28de5931056d.tar.gz
gcc-31ce2e993d09dcad1ce139a2848a28de5931056d.tar.bz2
Fold: Fix up merge_truthop_with_opposite_arm for NaNs [PR95351]
The problem here is that merge_truthop_with_opposite_arm would use the type of the result of the comparison rather than the operands of the comparison to figure out if we are honoring NaNs. This fixes that oversight and now we get the correct results in this case. Committed as obvious after a bootstrap/test on x86_64-linux-gnu. PR middle-end/95351 gcc/ChangeLog: * fold-const.cc (merge_truthop_with_opposite_arm): Use the type of the operands of the comparison and not the type of the comparison. gcc/testsuite/ChangeLog: * gcc.dg/float_opposite_arm-1.c: New test. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
Diffstat (limited to 'gcc/fold-const.cc')
-rw-r--r--gcc/fold-const.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index 43105d2..299c22b 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -6420,7 +6420,6 @@ static tree
merge_truthop_with_opposite_arm (location_t loc, tree op, tree cmpop,
bool rhs_only)
{
- tree type = TREE_TYPE (cmpop);
enum tree_code code = TREE_CODE (cmpop);
enum tree_code truthop_code = TREE_CODE (op);
tree lhs = TREE_OPERAND (op, 0);
@@ -6436,6 +6435,8 @@ merge_truthop_with_opposite_arm (location_t loc, tree op, tree cmpop,
if (TREE_CODE_CLASS (code) != tcc_comparison)
return NULL_TREE;
+ tree type = TREE_TYPE (TREE_OPERAND (cmpop, 0));
+
if (rhs_code == truthop_code)
{
tree newrhs = merge_truthop_with_opposite_arm (loc, rhs, cmpop, rhs_only);