public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* RFA: PATCH to match.pd for c++/68385
@ 2015-11-20 19:58 Jason Merrill
  2015-11-20 20:38 ` Jason Merrill
  2015-11-21  6:31 ` Richard Biener
  0 siblings, 2 replies; 7+ messages in thread
From: Jason Merrill @ 2015-11-20 19:58 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches List, Ramana Radhakrishnan

[-- Attachment #1: Type: text/plain, Size: 673 bytes --]

In this bug, we hit the (A & sign-bit) != 0 -> A < 0 transformation. 
Because of delayed folding, the operands aren't fully folded yet, so we 
have NOP_EXPRs around INTEGER_CSTs, and so calling wi::only_sign_bit_p 
ICEs.  We've been seeing several similar bugs, where code calls 
integer_zerop and therefore assumes that they have an INTEGER_CST, but 
in fact integer_zerop does STRIP_NOPS.

This patch changes the pattern to only match if the operand is actually 
an INTEGER_CST.  Alternatively we could call tree_strip_nop_conversions 
on the operand, but I would expect that to have issues when the 
conversion changes the signedness of the type.

OK if testing passes?

[-- Attachment #2: 68385.patch --]
[-- Type: text/x-patch, Size: 778 bytes --]

commit e7b45ed6775c88c6d48c5863738ba0db2e38fc5e
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Nov 20 14:40:35 2015 -0500

    	PR c++/68385
    
    	* match.pd: Don't assume that integer_pow2p implies INTEGER_CST.

diff --git a/gcc/match.pd b/gcc/match.pd
index e86cc8b..1981ae7 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -2232,6 +2232,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
        && (TYPE_PRECISION (TREE_TYPE (@0))
 	   == GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (@0))))
        && element_precision (@2) >= element_precision (@0)
+       && TREE_CODE (@1) == INTEGER_CST
        && wi::only_sign_bit_p (@1, element_precision (@0)))
    (with { tree stype = signed_type_for (TREE_TYPE (@0)); }
     (ncmp (convert:stype @0) { build_zero_cst (stype); })))))

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-11-24  9:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-20 19:58 RFA: PATCH to match.pd for c++/68385 Jason Merrill
2015-11-20 20:38 ` Jason Merrill
2015-11-21  6:31 ` Richard Biener
2015-11-21 19:19   ` Marc Glisse
2015-11-23 10:17     ` Richard Biener
2015-11-23 19:07   ` Jason Merrill
2015-11-24  9:40     ` Richard Biener

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).