public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-8263] reassoc: Don't call fold_convert if !fold_convertible_p [PR105374]
@ 2022-04-26  7:58 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2022-04-26  7:58 UTC (permalink / raw)
  To: gcc-cvs

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

commit r12-8263-gd4836ac9acd0c991a4fe1dec9438773a2c4eb5ac
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Apr 26 09:57:34 2022 +0200

    reassoc: Don't call fold_convert if !fold_convertible_p [PR105374]
    
    As mentioned in the PR, we ICE because maybe_fold_*_comparisons returns
    an expression with V4SImode type and we try to fold_convert it to
    V4BImode, which isn't allowed.
    
    IMHO no matter whether we change maybe_fold_*_comparisons we should
    play safe on the reassoc side and punt if we can't convert like
    we punt for many other reasons.  This fixes the testcase on ARM.
    
    Testcase not included, not exactly sure where and what directives it
    should have in gcc.target/arm/ testsuite.  Christophe, do you think you
    could handle that incrementally?
    
    2022-04-26  Jakub Jelinek  <jakub@redhat.com>
    
            PR tree-optimization/105374
            * tree-ssa-reassoc.cc (eliminate_redundant_comparison): Punt if
            !fold_convertible_p rather than assuming fold_convert must succeed.

Diff:
---
 gcc/tree-ssa-reassoc.cc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-ssa-reassoc.cc b/gcc/tree-ssa-reassoc.cc
index f41b3c9a004..43b25371d4b 100644
--- a/gcc/tree-ssa-reassoc.cc
+++ b/gcc/tree-ssa-reassoc.cc
@@ -2254,7 +2254,11 @@ eliminate_redundant_comparison (enum tree_code opcode,
 	 BIT_AND_EXPR or BIT_IOR_EXPR was of a wider integer type,
 	 we need to convert.  */
       if (!useless_type_conversion_p (TREE_TYPE (curr->op), TREE_TYPE (t)))
-	t = fold_convert (TREE_TYPE (curr->op), t);
+	{
+	  if (!fold_convertible_p (TREE_TYPE (curr->op), t))
+	    continue;
+	  t = fold_convert (TREE_TYPE (curr->op), t);
+	}
 
       if (TREE_CODE (t) != INTEGER_CST
 	  && !operand_equal_p (t, curr->op, 0))


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-26  7:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-26  7:58 [gcc r12-8263] reassoc: Don't call fold_convert if !fold_convertible_p [PR105374] Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).