This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/82170] gcc optimizes int range-checking poorly on x86-64
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 14 Sep 2017 10:04:45 +0000
- Subject: [Bug target/82170] gcc optimizes int range-checking poorly on x86-64
- Auto-submitted: auto-generated
- References: <bug-82170-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82170
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
To summarize IRC discussions about this, the first step should be to introduce
SEXT_EXPR (split from Prathamesh's patch, improve), then add match.pd
canonicalization of these range testing to SEXT_EXPR + EQ_EXPR/NE_EXPR or
BIT_AND_EXPR + EQ/NE, recognize those in range discovery for reassoc.
Combine probably isn't able to handle transformation of one seq to the other,
and in any case, combiner would be only one way (it simplifies/canonicalizes
the IL to something, but doesn't have easy way to try two completely different
but equivalent sequences; also, often it is more than 4 instructions).
So we should try to do something in the expansion to try both sequences and
pick the less costly.