On Tue, Oct 26, 2021 at 03:21:55PM +0200, Richard Biener wrote:
> On Tue, 26 Oct 2021, Jakub Jelinek wrote:
> 
> > On Tue, Oct 26, 2021 at 03:13:29PM +0200, Richard Biener wrote:
> > > try
> > >   auto c = ...;
> > >   signed char c2 = c;
> > >   return c2 >= ...
> > > then
> > 
> > That won't work, at least when using <compare>, which is what we with the
> > optimization want to deal with primarily.
> > Because std::partial_ordering etc. aren't implicitly nor explicitly
> > convertible to int or signed char etc.
> > Sure, one could in the testcase define its own std::strong_ordering etc.
> > and define a conversion operator for it...
> 
> So how do we end up with the signed char case in the first place?
> Is the frontend using a type that's target dependent?

<compare> uses explicitly signed char:
namespace std
{
  // [cmp.categories], comparison category types
  namespace __cmp_cat
  {
    using type = signed char;
    enum class _Ord : type { equivalent = 0, less = -1, greater = 1 };
    enum class _Ncmp : type { _Unordered = 2 };
...
and __cmp_cat::type is what is used as type of _M_value of std::*_ordering
-fsigned-char vs. -funsigned-char make no difference on the testcases on
x86, but as mentioned in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94589#c24
some target decisions like load_extend_op uses in fold-const.c can affect
it.  See https://gcc.gnu.org/pipermail/gcc-patches/2021-May/570714.html

        Jakub

Reply via email to