Mathematically correct result from maybe_lt, maybe_le and derivatives (using type traits) #179
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!179
Loading…
Reference in a new issue
No description provided.
Delete branch "chris.bazley/gcc:myforge/comparisons"
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?
Most of the poly_int functions don't handle mixed signed/unsigned
parameter types correctly, but it is relatively easy to make
the comparison functions do so:
the standard C++ comparison operator.
two types mismatches (1) then the second operand's value is
positive or zero, which is greater than the first operand's value
if the latter is negative.
two types mismatches (1) then the first operand's value is
positive or zero, which is greater than the second operand's value
if the latter is negative.
common type then use the standard C++ comparison operator.
Using type traits is likely to be more efficient than relying
on the fact that unsigned types never have a negative value,
because it avoids unnecessary comparisons in the case where
one or more of the operands has a signed type.
It would not be straightforward to make use of existing unsigned
test cases because they rely on implicit conversion of negative
integers to unsigned types, therefore I followed the following
method instead:
coefficient type specified by the user of the template, otherwise
the unsigned coefficient type.
coefficients and do not have operands of types with different
signedness.
modify them such that one version has the first operand of signed
type and the other has the second operand of signed type.
unsigned types have a non-negative value, trying to preserve intent,
ordering, and relative distance between values.
CC: rdsandiford@googlemail.com, tamar.christina@arm.com
Hi @chris.bazley. 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).I used these functions as part of my work on gcc/gcc-TEST#176 and found they don't work for mixed signed / unsigned operand types. I think it might be worth fixing that to prevent future surprises.
This approach is an alternative to the one that I used in gcc/gcc-TEST#180 because I was not sure which was more likely to be accepted. The tests are identical. Please state your preference, if any.
78205f10f2f3c820ee53f3c820ee5330f8accc4630f8accc460d0033f3d8I don't think we want to do this. known_lt should behave like < for most targets. That includes warning when comparing signed and unsigned types of the same size. So it's a feature, not a bug, that:
generates a warning (or an error, when bootstrapping).
Mathematically correct result from maybe_lt, maybe_le and derivativesto Mathematically correct result from maybe_lt, maybe_le and derivatives (using type traits)View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.