match: Simplify value-range guarded min/max expressions [PR125700] #214
No reviewers
Labels
No labels
Compat/Breaking
Frontend/ada
Frontend/c
Frontend/c++
Frontend/rust
General/forge
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Library/libgcc
Library/libstdc++
Midend/gimple
Midend/rtl
Midend/tree
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
Target/aarch64
Target/arm
Target/i386
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gcc/gcc!214
Loading…
Reference in a new issue
No description provided.
Delete branch "sam-100/gcc:pr125700"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The pattern:
can be simplified to min (x, y) whenever C >= upper_bound (y),
because min (C, y) == y for all values y can take. Similarly:
can be simplified to max (x, y) whenever C <= lower_bound (y).
Use ranger to query the value range of y and check the bound condition.
gcc/ChangeLog:
PR tree-optimization/125700
* match.pd ((x == C) ? y : MIN/MAX (x, y)): New simplification.
gcc/testsuite/ChangeLog:
Signed-off-by: Samarth Tandale samarth.tandale@oss.qualcomm.com
Testing:
Regression tested a cross compiler targeting AArch64 GNU/Linux on an
x86_64 GNU/Linux host, with execution tests run under QEMU; no
regressions found.
Changes since v1:
when Ranger proves their relationship with y's value range and conservatively
falls back when no useful range is available.
CC: andrew.pinski@oss.qualcomm.com
Hi @sam-100. This bot helps send your PR as a patch series to the mailing list.
Next steps
CC: Reviewer1 <revi.ewer@example.com>, Reviewer2 <an.other@example.com>./preview./submit.Changes since vXsection, and comment with/submitagain.See Submitting Patches and UsingForge.
Consider joining the gcc and gcc-patches mailing lists..
For real time communication, check the gcc irc channels.
Or join
#overseerson Libera Chat, particularly if this automation is not working (stay online to get replies, IRC does not save messages if people are not online).@ -12710,0 +12719,4 @@(with {tree bound = (minmax == MIN_EXPR)? TYPE_MAX_VALUE (type): TYPE_MIN_VALUE (type);I think we should use the ranger here.
Similar to minmax_from_comparison.
It should be something like
Then the if would be:
if (max == wi::to_widdest (@0))
I tried using the ranger as suggested. However, get_range_query (cfun)->range_of_expr (r, @0) does not to consider the conditional context in which @0 is being queried, so it does not provide the path-specific range established by the surrounding condition.
I also tried gimple_match_range_of_expr (r, @0, @0). However, the helper uses gimple_match_ctx (@0), which provides the definition statement of @0 as the context. In this case, that statement is outside the if (x <= 100) block, so the conditional range is still not considered.
Could you please verify whether this is the intended use of the ranger, or advise how to query the range of @0 using the current conditional context?
Version 1 of this pull request has been stored. It includes the following commits:
4d042112a64d042112a67e709962d4/preview
Sent patch version 2 as a single email to @sam-100's email address.
Message ID is
<bmm.hmfovtrc2o.gcc.gcc.sam-100.214.2.0@forge-stage.sourceware.org>./submit
Version 2 of this pull request has been stored. It includes the following commits:
7e709962d4Pull Request versions:
19a304d3684d042112a67f405dfaa27e709962d4In order to compare , clone this repository and run
Sent patch version 2 as a single email to gcc-patches mailing list gcc-patches@gcc.gnu.org and cc'd andrew.pinski@oss.qualcomm.com.
Cover letter
match: Simplify type-bound guarded min/max expressions [PR125700]to match: Simplify range-bound guarded min/max expressions [PR125700]match: Simplify range-bound guarded min/max expressions [PR125700]to match: Simplify value-range guarded min/max expressions [PR125700]Pull request closed