From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH][12/n] Remove GENERIC stmt combining from SCCVN
Date: Thu, 02 Jul 2015 14:09:00 -0000 [thread overview]
Message-ID: <alpine.LSU.2.11.1507021606250.9923@zhemvz.fhfr.qr> (raw)
This moves the alignment folding to a match.pd pattern (it's
surprising how often the old one triggered via SCCVN stmt combining).
Bootstrap and regtest running on x86_64-unknown-linux-gnu.
Richard.
2015-07-02 Richard Biener <rguenther@suse.de>
* fold-const.c (fold_binary_loc): Move (T)ptr & CST folding...
* match.pd: ... here.
Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c (revision 225312)
+++ gcc/fold-const.c (working copy)
@@ -11069,25 +10729,6 @@ fold_binary_loc (location_t loc,
fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0));
}
- /* If arg0 is derived from the address of an object or function, we may
- be able to fold this expression using the object or function's
- alignment. */
- if (POINTER_TYPE_P (TREE_TYPE (arg0)) && TREE_CODE (arg1) == INTEGER_CST)
- {
- unsigned int align;
- unsigned HOST_WIDE_INT bitpos;
-
- get_pointer_alignment_1 (arg0, &align, &bitpos);
-
- /* This works because modulus is a power of 2. If this weren't the
- case, we'd have to replace it by its greatest power-of-2
- divisor: modulus & -modulus. */
- if (wi::ltu_p (arg1, align / BITS_PER_UNIT))
- return wide_int_to_tree (type,
- wi::bit_and (arg1,
- bitpos / BITS_PER_UNIT));
- }
-
goto associate;
case RDIV_EXPR:
Index: gcc/match.pd
===================================================================
--- gcc/match.pd (revision 225312)
+++ gcc/match.pd (working copy)
@@ -668,6 +688,21 @@ (define_operator_list swapped_tcc_compar
(if (ptr_difference_const (@0, @1, &diff))
{ build_int_cst_type (type, diff); }))))
+/* If arg0 is derived from the address of an object or function, we may
+ be able to fold this expression using the object or function's
+ alignment. */
+(simplify
+ (bit_and (convert? @0) INTEGER_CST@1)
+ (if (POINTER_TYPE_P (TREE_TYPE (@0))
+ && tree_nop_conversion_p (type, TREE_TYPE (@0)))
+ (with
+ {
+ unsigned int align;
+ unsigned HOST_WIDE_INT bitpos;
+ get_pointer_alignment_1 (@0, &align, &bitpos);
+ }
+ (if (wi::ltu_p (@1, align / BITS_PER_UNIT))
+ { wide_int_to_tree (type, wi::bit_and (@1, bitpos / BITS_PER_UNIT)); }))))
/* We can't reassociate at all for saturating types. */
reply other threads:[~2015-07-02 14:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LSU.2.11.1507021606250.9923@zhemvz.fhfr.qr \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).