[committed] openmp: Partial OpenMP 5.2 doacross and omp_cur_iteration support

2022-09-03 Thread Jakub Jelinek via Gcc-patches
Hi!

The following patch implements part of the OpenMP 5.2 changes related
to ordered loops and with the assumed resolution of
https://github.com/OpenMP/spec/issues/3302 issues.

The changes are:
1) the depend clause on stand-alone ordered constructs has been renamed
   to doacross (because depend clause has different syntax on other
   constructs) with some syntax changes below, depend clause is deprecated
   (we'll deprecate stuff on the GCC side only when we have everything else
   from 5.2 implemented)
   depend(source) -> doacross(source:) or doacross(source:omp_cur_iteration)
   depend(sink:vec) -> doacross(sink:vec) (where vec has the same syntax
   as before)
2) in 5.1 and before it has been significant whether ordered clause has or
   doesn't have an argument, if it didn't, only block-associated ordered
   could appear in the body, if it did, only stand-alone ordered could appear
   in the body, all loops had to be perfectly nested, no associated
   range-based for loops, no linear clause on work-sharing loop and ordered
   clause with an argument wasn't allowed on composite for simd.
   In 5.2, whether ordered clause has or doesn't have an argument is
   insignificant (except for bugs in the standard, #3302 mentions those),
   if the argument is missing, it is simply treated as equal to collapse
   argument (if any, otherwise 1).  The implementation better should be able
   to differentiate between ordered and doacross loops at compile time
   which previously was through the absence or presence of the argument,
   now it is done through looking at the body of the construct lexically
   and looking for stand-alone ordered constructs.  If there are any,
   it is to be handled as doacross loop, otherwise it is ordered loop
   (but in that case ordered argument if present must be equal to collapse
   argument - 5.2 says instead it must be one, but that is clearly wrong
   and mentioned in #3302) - stand-alone ordered constructs must appear
   lexically in the body (and had to before as well).  For the restrictions
   mentioned above, the for simd restriction is gone (stand-alone ordered
   can't appear in simd construct, so that is enough), and the other rules
   are expected to be changed into something related to presence of
   stand-alone ordered constructs in the body
3) 5.2 allows a new syntax, doacross(sink:omp_cur_iteration-1), which
   means wait for previous iteration in the iteration space of all the
   associated loops

The following patch implements that, except that we sorry for now
on the doacross(sink:omp_cur_iteration-1) syntax during omp expansion
because library side isn't done yet for it.  It doesn't implement it for
the Fortran FE either.
Incrementally, I'd like to change the way we differentiate between
stand-alone and block-associated ordered constructs, because the current
way of looking for presence of doacross clause doesn't work well if those
clauses are removed because they had been invalid (wrong syntax or
unknown variables in it etc.) and of course implement
doacross(sink:omp_cur_iteration-1).

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.

2022-09-03  Jakub Jelinek  

gcc/
* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_DOACROSS.
(enum omp_clause_depend_kind): Remove OMP_CLAUSE_DEPEND_SOURCE
and OMP_CLAUSE_DEPEND_SINK, add OMP_CLAUSE_DEPEND_INVALID.
(enum omp_clause_doacross_kind): New type.
(struct tree_omp_clause): Add subcode.doacross_kind member.
* tree.h (OMP_CLAUSE_DEPEND_SINK_NEGATIVE): Remove.
(OMP_CLAUSE_DOACROSS_KIND): Define.
(OMP_CLAUSE_DOACROSS_SINK_NEGATIVE): Define.
(OMP_CLAUSE_DOACROSS_DEPEND): Define.
(OMP_CLAUSE_ORDERED_DOACROSS): Define.
* tree.cc (omp_clause_num_ops, omp_clause_code_name): Add
OMP_CLAUSE_DOACROSS entries.
* tree-nested.cc (convert_nonlocal_omp_clauses,
convert_local_omp_clauses): Handle OMP_CLAUSE_DOACROSS.
* tree-pretty-print.cc (dump_omp_clause): Don't handle
OMP_CLAUSE_DEPEND_SOURCE and OMP_CLAUSE_DEPEND_SINK.  Handle
OMP_CLAUSE_DOACROSS.
* gimplify.cc (gimplify_omp_depend): Don't handle
OMP_CLAUSE_DEPEND_SOURCE and OMP_CLAUSE_DEPEND_SINK.
(gimplify_scan_omp_clauses): Likewise.  Handle OMP_CLAUSE_DOACROSS.
(gimplify_adjust_omp_clauses): Handle OMP_CLAUSE_DOACROSS.
(find_standalone_omp_ordered): New function.
(gimplify_omp_for): When OMP_CLAUSE_ORDERED is present, search
body for OMP_ORDERED with OMP_CLAUSE_DOACROSS and if found,
set OMP_CLAUSE_ORDERED_DOACROSS.
(gimplify_omp_ordered): Don't handle OMP_CLAUSE_DEPEND_SINK or
OMP_CLAUSE_DEPEND_SOURCE, instead check OMP_CLAUSE_DOACROSS, adjust
diagnostics that presence or absence of ordered clause parameter
is irrelevant.  Handle doacross(sink:omp_cur_iteration-1).  Use
actual

[PATCH] libcpp, v3: Named universal character escapes and delimited escape sequence tweaks

2022-09-03 Thread Jakub Jelinek via Gcc-patches
On Thu, Sep 01, 2022 at 03:00:28PM -0400, Jason Merrill wrote:
> We might as well use the same flag name, and document it to mean what it
> currently means for GCC.

Ok, following patch introduces -Wunicode (on by default).

> It looks like this is handling \N{abc}, for which "incomplete" seems like
> the wrong description; it's complete, just wrong, and the diagnostic doesn't
> help correct it.

And also will emit the is not a valid universal character with did you mean
if it matches loosely, otherwise will use the not terminated with } after
... wording.

Ok if it passes bootstrap/regtest?

2022-09-03  Jakub Jelinek  

libcpp/
* include/cpplib.h (struct cpp_options): Add cpp_warn_unicode member.
(enum cpp_warning_reason): Add CPP_W_UNICODE.
* init.cc (cpp_create_reader): Initialize cpp_warn_unicode.
* charset.cc (_cpp_valid_ucn): In possible identifier contexts, don't
handle \u{ or \N{ specially in -std=c* modes except -std=c++2{3,b}.
In possible identifier contexts, don't emit an error and punt
if \N isn't followed by {, or if \N{} surrounds some lower case
letters or _.  In possible identifier contexts when not C++23, don't
emit an error but warning about unknown character names and treat as
separate tokens.  When treating as separate tokens \u{ or \N{, emit
warnings.
gcc/
* doc/invoke.texi (-Wno-unicode): Document.
gcc/c-family/
* c.opt (Winvalid-utf8): Use ObjC instead of objC.  Remove
" in comments" from description.
(Wunicode): New option.
gcc/testsuite/
* c-c++-common/cpp/delimited-escape-seq-4.c: New test.
* c-c++-common/cpp/delimited-escape-seq-5.c: New test.
* c-c++-common/cpp/delimited-escape-seq-6.c: New test.
* c-c++-common/cpp/delimited-escape-seq-7.c: New test.
* c-c++-common/cpp/named-universal-char-escape-5.c: New test.
* c-c++-common/cpp/named-universal-char-escape-6.c: New test.
* c-c++-common/cpp/named-universal-char-escape-7.c: New test.
* g++.dg/cpp23/named-universal-char-escape1.C: New test.
* g++.dg/cpp23/named-universal-char-escape2.C: New test.

--- libcpp/include/cpplib.h.jj  2022-09-03 09:35:41.465984642 +0200
+++ libcpp/include/cpplib.h 2022-09-03 11:30:57.250677870 +0200
@@ -565,6 +565,10 @@ struct cpp_options
  2 if it should be a pedwarn.  */
   unsigned char cpp_warn_invalid_utf8;
 
+  /* True if libcpp should warn about invalid forms of delimited or named
+ escape sequences.  */
+  bool cpp_warn_unicode;
+
   /* True if -finput-charset= option has been used explicitly.  */
   bool cpp_input_charset_explicit;
 
@@ -675,7 +679,8 @@ enum cpp_warning_reason {
   CPP_W_CXX20_COMPAT,
   CPP_W_EXPANSION_TO_DEFINED,
   CPP_W_BIDIRECTIONAL,
-  CPP_W_INVALID_UTF8
+  CPP_W_INVALID_UTF8,
+  CPP_W_UNICODE
 };
 
 /* Callback for header lookup for HEADER, which is the name of a
--- libcpp/init.cc.jj   2022-09-01 09:47:23.729892618 +0200
+++ libcpp/init.cc  2022-09-03 11:19:10.954452329 +0200
@@ -228,6 +228,7 @@ cpp_create_reader (enum c_lang lang, cpp
   CPP_OPTION (pfile, warn_date_time) = 0;
   CPP_OPTION (pfile, cpp_warn_bidirectional) = bidirectional_unpaired;
   CPP_OPTION (pfile, cpp_warn_invalid_utf8) = 0;
+  CPP_OPTION (pfile, cpp_warn_unicode) = 1;
   CPP_OPTION (pfile, cpp_input_charset_explicit) = 0;
 
   /* Default CPP arithmetic to something sensible for the host for the
--- libcpp/charset.cc.jj2022-09-01 14:19:47.462235851 +0200
+++ libcpp/charset.cc   2022-09-03 11:26:14.858585905 +0200
@@ -1448,7 +1448,11 @@ _cpp_valid_ucn (cpp_reader *pfile, const
   if (str[-1] == 'u')
 {
   length = 4;
-  if (str < limit && *str == '{')
+  if (str < limit
+ && *str == '{'
+ && (!identifier_pos
+ || CPP_OPTION (pfile, delimited_escape_seqs)
+ || !CPP_OPTION (pfile, std)))
{
  str++;
  /* Magic value to indicate no digits seen.  */
@@ -1462,8 +1466,22 @@ _cpp_valid_ucn (cpp_reader *pfile, const
   else if (str[-1] == 'N')
 {
   length = 4;
+  if (identifier_pos
+ && !CPP_OPTION (pfile, delimited_escape_seqs)
+ && CPP_OPTION (pfile, std))
+   {
+ *cp = 0;
+ return false;
+   }
   if (str == limit || *str != '{')
-   cpp_error (pfile, CPP_DL_ERROR, "'\\N' not followed by '{'");
+   {
+ if (identifier_pos)
+   {
+ *cp = 0;
+ return false;
+   }
+ cpp_error (pfile, CPP_DL_ERROR, "'\\N' not followed by '{'");
+   }
   else
{
  str++;
@@ -1472,6 +1490,7 @@ _cpp_valid_ucn (cpp_reader *pfile, const
  length = 0;
  const uchar *name = str;
  bool strict = true;
+ const uchar *strict_end = name;
 
  do
{
@@ -1481,7 +1500,11 @@ _cpp_valid_ucn (cpp_reader *pfile, const
  if (!ISIDNUM (c) && c != ' ' && 

Re: [PATCH] libcpp, v3: Named universal character escapes and delimited escape sequence tweaks

2022-09-03 Thread Jakub Jelinek via Gcc-patches
On Sat, Sep 03, 2022 at 12:29:52PM +0200, Jakub Jelinek wrote:
> On Thu, Sep 01, 2022 at 03:00:28PM -0400, Jason Merrill wrote:
> > We might as well use the same flag name, and document it to mean what it
> > currently means for GCC.
> 
> Ok, following patch introduces -Wunicode (on by default).
> 
> > It looks like this is handling \N{abc}, for which "incomplete" seems like
> > the wrong description; it's complete, just wrong, and the diagnostic doesn't
> > help correct it.
> 
> And also will emit the is not a valid universal character with did you mean
> if it matches loosely, otherwise will use the not terminated with } after
> ... wording.
> 
> Ok if it passes bootstrap/regtest?

Actually, treating the !strict case like the strict case except for always
warning instead of error if outside of literals is simpler.

The following version does that.  The only difference on the testcases is in
the
int f = a\N{abc});
cases where it emits different diagnostics.

2022-09-03  Jakub Jelinek  

libcpp/
* include/cpplib.h (struct cpp_options): Add cpp_warn_unicode member.
(enum cpp_warning_reason): Add CPP_W_UNICODE.
* init.cc (cpp_create_reader): Initialize cpp_warn_unicode.
* charset.cc (_cpp_valid_ucn): In possible identifier contexts, don't
handle \u{ or \N{ specially in -std=c* modes except -std=c++2{3,b}.
In possible identifier contexts, don't emit an error and punt
if \N isn't followed by {, or if \N{} surrounds some lower case
letters or _.  In possible identifier contexts when not C++23, don't
emit an error but warning about unknown character names and treat as
separate tokens.  When treating as separate tokens \u{ or \N{, emit
warnings.
gcc/
* doc/invoke.texi (-Wno-unicode): Document.
gcc/c-family/
* c.opt (Winvalid-utf8): Use ObjC instead of objC.  Remove
" in comments" from description.
(Wunicode): New option.
gcc/testsuite/
* c-c++-common/cpp/delimited-escape-seq-4.c: New test.
* c-c++-common/cpp/delimited-escape-seq-5.c: New test.
* c-c++-common/cpp/delimited-escape-seq-6.c: New test.
* c-c++-common/cpp/delimited-escape-seq-7.c: New test.
* c-c++-common/cpp/named-universal-char-escape-5.c: New test.
* c-c++-common/cpp/named-universal-char-escape-6.c: New test.
* c-c++-common/cpp/named-universal-char-escape-7.c: New test.
* g++.dg/cpp23/named-universal-char-escape1.C: New test.
* g++.dg/cpp23/named-universal-char-escape2.C: New test.

--- libcpp/include/cpplib.h.jj  2022-09-03 09:35:41.465984642 +0200
+++ libcpp/include/cpplib.h 2022-09-03 11:30:57.250677870 +0200
@@ -565,6 +565,10 @@ struct cpp_options
  2 if it should be a pedwarn.  */
   unsigned char cpp_warn_invalid_utf8;
 
+  /* True if libcpp should warn about invalid forms of delimited or named
+ escape sequences.  */
+  bool cpp_warn_unicode;
+
   /* True if -finput-charset= option has been used explicitly.  */
   bool cpp_input_charset_explicit;
 
@@ -675,7 +679,8 @@ enum cpp_warning_reason {
   CPP_W_CXX20_COMPAT,
   CPP_W_EXPANSION_TO_DEFINED,
   CPP_W_BIDIRECTIONAL,
-  CPP_W_INVALID_UTF8
+  CPP_W_INVALID_UTF8,
+  CPP_W_UNICODE
 };
 
 /* Callback for header lookup for HEADER, which is the name of a
--- libcpp/init.cc.jj   2022-09-01 09:47:23.729892618 +0200
+++ libcpp/init.cc  2022-09-03 11:19:10.954452329 +0200
@@ -228,6 +228,7 @@ cpp_create_reader (enum c_lang lang, cpp
   CPP_OPTION (pfile, warn_date_time) = 0;
   CPP_OPTION (pfile, cpp_warn_bidirectional) = bidirectional_unpaired;
   CPP_OPTION (pfile, cpp_warn_invalid_utf8) = 0;
+  CPP_OPTION (pfile, cpp_warn_unicode) = 1;
   CPP_OPTION (pfile, cpp_input_charset_explicit) = 0;
 
   /* Default CPP arithmetic to something sensible for the host for the
--- libcpp/charset.cc.jj2022-09-01 14:19:47.462235851 +0200
+++ libcpp/charset.cc   2022-09-03 12:42:41.800923600 +0200
@@ -1448,7 +1448,11 @@ _cpp_valid_ucn (cpp_reader *pfile, const
   if (str[-1] == 'u')
 {
   length = 4;
-  if (str < limit && *str == '{')
+  if (str < limit
+ && *str == '{'
+ && (!identifier_pos
+ || CPP_OPTION (pfile, delimited_escape_seqs)
+ || !CPP_OPTION (pfile, std)))
{
  str++;
  /* Magic value to indicate no digits seen.  */
@@ -1462,8 +1466,22 @@ _cpp_valid_ucn (cpp_reader *pfile, const
   else if (str[-1] == 'N')
 {
   length = 4;
+  if (identifier_pos
+ && !CPP_OPTION (pfile, delimited_escape_seqs)
+ && CPP_OPTION (pfile, std))
+   {
+ *cp = 0;
+ return false;
+   }
   if (str == limit || *str != '{')
-   cpp_error (pfile, CPP_DL_ERROR, "'\\N' not followed by '{'");
+   {
+ if (identifier_pos)
+   {
+ *cp = 0;
+ return false;
+   }
+ cpp_error (pfile, CPP_DL_ERROR, "'\\N' not followed by '{'");
+ 

[PATCH] Add real_isdenormal.

2022-09-03 Thread Aldy Hernandez via Gcc-patches
There are 6 idioms of the same check and I'd like to add more.

It seems there are macros as well as functions for things like
REAL_VALUE_ISINF and REAL_VALUE_NEGATIVE.  I don't know if there was
historical need for this duplicity, but I think it's cleaner if we
start gravitating towards inline functions only.

OK?

gcc/ChangeLog:

* real.cc (encode_ieee_single): Use real_isdenormal.
(encode_ieee_double): Same.
(encode_ieee_extended): Same.
(encode_ieee_quad): Same.
(encode_ieee_half): Same.
(encode_arm_bfloat_half): Same.
* real.h (real_isdenormal): New.
---
 gcc/real.cc | 12 ++--
 gcc/real.h  |  7 +++
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/gcc/real.cc b/gcc/real.cc
index 96f05ec68ca..73bbac645d9 100644
--- a/gcc/real.cc
+++ b/gcc/real.cc
@@ -2954,7 +2954,7 @@ encode_ieee_single (const struct real_format *fmt, long 
*buf,
 {
   unsigned long image, sig, exp;
   unsigned long sign = r->sign;
-  bool denormal = (r->sig[SIGSZ-1] & SIG_MSB) == 0;
+  bool denormal = real_isdenormal (r);
 
   image = sign << 31;
   sig = (r->sig[SIGSZ-1] >> (HOST_BITS_PER_LONG - 24)) & 0x7f;
@@ -3175,7 +3175,7 @@ encode_ieee_double (const struct real_format *fmt, long 
*buf,
 {
   unsigned long image_lo, image_hi, sig_lo, sig_hi, exp;
   unsigned long sign = r->sign;
-  bool denormal = (r->sig[SIGSZ-1] & SIG_MSB) == 0;
+  bool denormal = real_isdenormal (r);
 
   image_hi = sign << 31;
   image_lo = 0;
@@ -3433,7 +3433,7 @@ encode_ieee_extended (const struct real_format *fmt, long 
*buf,
  const REAL_VALUE_TYPE *r)
 {
   unsigned long image_hi, sig_hi, sig_lo;
-  bool denormal = (r->sig[SIGSZ-1] & SIG_MSB) == 0;
+  bool denormal = real_isdenormal (r);
 
   image_hi = r->sign << 15;
   sig_hi = sig_lo = 0;
@@ -3964,7 +3964,7 @@ encode_ieee_quad (const struct real_format *fmt, long 
*buf,
 {
   unsigned long image3, image2, image1, image0, exp;
   unsigned long sign = r->sign;
-  bool denormal = (r->sig[SIGSZ-1] & SIG_MSB) == 0;
+  bool denormal = real_isdenormal (r);
   REAL_VALUE_TYPE u;
 
   image3 = sign << 31;
@@ -4721,7 +4721,7 @@ encode_ieee_half (const struct real_format *fmt, long 
*buf,
 {
   unsigned long image, sig, exp;
   unsigned long sign = r->sign;
-  bool denormal = (r->sig[SIGSZ-1] & SIG_MSB) == 0;
+  bool denormal = real_isdenormal (r);
 
   image = sign << 15;
   sig = (r->sig[SIGSZ-1] >> (HOST_BITS_PER_LONG - 11)) & 0x3ff;
@@ -4835,7 +4835,7 @@ encode_arm_bfloat_half (const struct real_format *fmt, 
long *buf,
 {
   unsigned long image, sig, exp;
   unsigned long sign = r->sign;
-  bool denormal = (r->sig[SIGSZ-1] & SIG_MSB) == 0;
+  bool denormal = real_isdenormal (r);
 
   image = sign << 15;
   sig = (r->sig[SIGSZ-1] >> (HOST_BITS_PER_LONG - 8)) & 0x7f;
diff --git a/gcc/real.h b/gcc/real.h
index 2f490ef9b72..f9528d765ec 100644
--- a/gcc/real.h
+++ b/gcc/real.h
@@ -286,6 +286,13 @@ extern bool real_isnan (const REAL_VALUE_TYPE *);
 /* Determine whether a floating-point value X is a signaling NaN.  */
 extern bool real_issignaling_nan (const REAL_VALUE_TYPE *);
 
+/* Determine whether a floating-point value X is a denormal.  */
+inline bool
+real_isdenormal (const REAL_VALUE_TYPE *r)
+{
+  return (r->sig[SIGSZ-1] & SIG_MSB) == 0;
+}
+
 /* Determine whether a floating-point value X is finite.  */
 extern bool real_isfinite (const REAL_VALUE_TYPE *);
 
-- 
2.37.1



[COMMITTED] [PR 106819] NANs can never be a singleton

2022-09-03 Thread Aldy Hernandez via Gcc-patches
Possible NANs can never be a singleton, so they will never be
propagated.  This was the intent, and then the signed zero code crept
in, and was mistakenly checked before the NAN.

PR 106819

gcc/ChangeLog:

* value-range.cc (frange::singleton_p): Move NAN check to the top.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr106819.c: New test.
---
 gcc/testsuite/gcc.dg/tree-ssa/pr106819.c | 24 
 gcc/value-range.cc   |  9 -
 2 files changed, 28 insertions(+), 5 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr106819.c

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr106819.c 
b/gcc/testsuite/gcc.dg/tree-ssa/pr106819.c
new file mode 100644
index 000..1272d4b5805
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr106819.c
@@ -0,0 +1,24 @@
+// { dg-do compile }
+// { dg-options "-O2 -fdump-tree-evrp-details" }
+
+static int isNaN(double x)
+{
+return x != x;
+}
+
+static double opCmpProper(int lhs, double rhs)
+{
+  return lhs < rhs ? -1.0
+   : lhs > rhs ? 1.0
+   : lhs == rhs ? 0.0
+   : __builtin_nan("");
+}
+
+int main()
+{
+if (!isNaN(opCmpProper(41, __builtin_nan(""
+  __builtin_abort();
+return 0;
+}
+
+// { dg-final {scan-tree-dump-not "Folds to: 0.0" "evrp" } }
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 6fd6e3b745c..a1c29f7bd0b 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -632,6 +632,10 @@ frange::singleton_p (tree *result) const
 {
   if (m_kind == VR_RANGE && real_identical (&m_min, &m_max))
 {
+  // Return false for any singleton that may be a NAN.
+  if (HONOR_NANS (m_type) && !get_nan ().no_p ())
+   return false;
+
   // Return the appropriate zero if known.
   if (HONOR_SIGNED_ZEROS (m_type) && zero_p ())
{
@@ -649,11 +653,6 @@ frange::singleton_p (tree *result) const
}
  return false;
}
-
-  // Return false for any singleton that may be a NAN.
-  if (HONOR_NANS (m_type) && !get_nan ().no_p ())
-   return false;
-
   if (result)
*result = build_real (m_type, m_min);
   return true;
-- 
2.37.1



[PATCH] c++: Implement C++23 P2266R1, Simpler implicit move [PR101165]

2022-09-03 Thread Marek Polacek via Gcc-patches
This patch implements https://wg21.link/p2266, which, once again,
changes the implicit move rules.  Here's a brief summary of various
changes in this area:

r125211: Introduced moving from certain lvalues when returning them
r171071: CWG 1148, enable move from value parameter on return
r212099: CWG 1579, it's OK to call a converting ctor taking an rvalue
r251035: CWG 1579, do maybe-rvalue overload resolution twice
r11-2411: Avoid calling const copy ctor on implicit move
r11-2412: C++20 implicit move changes, remove the fallback overload
  resolution, allow move on throw of parameters and implicit
  move of rvalue references

P2266 enables the implicit move for functions that return references.  This
was a one-line change: check TYPE_REF_P.  That is, we will now perform
a move in

  X&& foo (X&& x) {
return x;
  }

P2266 also removes the fallback overload resolution, but this was
resolved by r11-2412: we only do convert_for_initialization with
LOOKUP_PREFER_RVALUE in C++17 and older.
P2266 also says that a returned move-eligible id-expression is always an
xvalue.  This required some further short, but nontrivial changes,
especially when it comes to deduction, because we have to pay attention
to whether we have auto, auto&& (which is like T&&), or decltype(auto)
with (un)parenthesized argument.  In C++23,

  decltype(auto) f(int&& x) { return (x); }
  auto&& f(int x) { return x; }

both should deduce to 'int&&' but

  decltype(auto) f(int x) { return x; }

should deduce to 'int'.  A cornucopia of tests attached.  I've also
verified that we behave like clang++.

xvalue_p seemed to be broken: since the introduction of clk_implicit_rval,
it cannot use '==' when checking for clk_rvalueref.

Since this change breaks code, it's only enabled in C++23.  In
particular, this code will not compile in C++23:

  int& g(int&& x) { return x; }

because x is now treated as an rvalue, and you can't bind a non-const lvalue
reference to an rvalue.

There's one FIXME in elision1.C:five, which we should compile but reject
with "passing 'Mutt' as 'this' argument discards qualifiers".  That
looks bogus to me, I think I'll open a PR for it.

Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

PR c++/101165

gcc/c-family/ChangeLog:

* c-cppbuiltin.cc (c_cpp_builtins): Define __cpp_implicit_move.

gcc/cp/ChangeLog:

* call.cc (reference_binding): Check clk_implicit_rval in C++20 only.
* cp-tree.h (unparenthesized_id_or_class_member_access_p): Declare.
* pt.cc (unparenthesized_id_or_class_member_access_p): New function,
broken out of...
(do_auto_deduction): ...here.  Use it.
* tree.cc (xvalue_p): Check & clk_rvalueref, not == clk_rvalueref.
* typeck.cc (check_return_expr): In C++23, maybe call
treat_lvalue_as_rvalue_p before do_auto_deduction.  Allow implicit
move for functions returning a reference as well.

gcc/testsuite/ChangeLog:

* g++.dg/conversion/pr41426.C: Add dg-error for C++23.
* g++.dg/cpp0x/elision_weak.C: Likewise.
* g++.dg/cpp0x/move-return3.C: Only link in c++20_down.
* g++.dg/cpp1y/decltype-auto2.C: Add dg-error for C++23.
* g++.dg/cpp1y/lambda-generic-89419.C: Likewise.
* g++.dg/cpp23/feat-cxx2b.C: Test __cpp_implicit_move.
* g++.dg/gomp/pr56217.C: Only compile in c++20_down.
* g++.dg/warn/Wno-return-local-addr.C: Add dg-error for C++23.
* g++.dg/warn/Wreturn-local-addr.C: Adjust dg-error.
* g++.old-deja/g++.brendan/crash55.C: Add dg-error for C++23.
* g++.old-deja/g++.jason/temporary2.C: Likewise.
* g++.old-deja/g++.mike/p2846b.C: Only run in c++20_down.
* g++.dg/cpp1y/decltype-auto6.C: New test.
* g++.dg/cpp23/decltype1.C: New test.
* g++.dg/cpp23/decltype2.C: New test.
* g++.dg/cpp23/elision1.C: New test.
* g++.dg/cpp23/elision2.C: New test.
* g++.dg/cpp23/elision3.C: New test.
* g++.dg/cpp23/elision4.C: New test.
* g++.dg/cpp23/elision5.C: New test.
* g++.dg/cpp23/elision6.C: New test.
* g++.dg/cpp23/elision7.C: New test.
---
 gcc/c-family/c-cppbuiltin.cc  |   1 +
 gcc/cp/call.cc|   2 +-
 gcc/cp/cp-tree.h  |   1 +
 gcc/cp/pt.cc  |  33 +++--
 gcc/cp/tree.cc|   2 +-
 gcc/cp/typeck.cc  |  28 -
 gcc/testsuite/g++.dg/conversion/pr41426.C |  10 +-
 gcc/testsuite/g++.dg/cpp0x/elision_weak.C |   4 +-
 gcc/testsuite/g++.dg/cpp0x/move-return3.C |   3 +-
 gcc/testsuite/g++.dg/cpp1y/decltype-auto2.C   |   2 +-
 gcc/testsuite/g++.dg/cpp1y/decltype-auto6.C   |  19 +++
 .../g++.dg/cpp1y/lambda-generic-89419.C   |   6 +-
 gcc/testsuite/g++.dg/cpp23/decltype1.C| 113 ++
 gcc/testsuite/g++.dg/cpp23/decltype2.C|  49 
 gc

Re: [PATCH] Add real_isdenormal.

2022-09-03 Thread Jeff Law via Gcc-patches




On 9/3/2022 7:48 AM, Aldy Hernandez via Gcc-patches wrote:

There are 6 idioms of the same check and I'd like to add more.

It seems there are macros as well as functions for things like
REAL_VALUE_ISINF and REAL_VALUE_NEGATIVE.  I don't know if there was
historical need for this duplicity, but I think it's cleaner if we
start gravitating towards inline functions only.

OK?

gcc/ChangeLog:

* real.cc (encode_ieee_single): Use real_isdenormal.
(encode_ieee_double): Same.
(encode_ieee_extended): Same.
(encode_ieee_quad): Same.
(encode_ieee_half): Same.
(encode_arm_bfloat_half): Same.
* real.h (real_isdenormal): New.
OK.  And if there's any followups where you're doing similar kinds of 
factoring of duplicated real.* code, consider such changes pre-approved.


jeff



Re: [PATCH 2/3] rename DBX_REGISTER_NUMBER to DEBUGGER_REGISTER_NUMBER

2022-09-03 Thread Jeff Law via Gcc-patches




On 9/2/2022 1:05 AM, Martin Liška wrote:

On 9/1/22 14:32, Michael Matz wrote:

Hello,

okay, I'll bite :)  DBG_REGISTER_NUMBER?  DEBUGGER_REGNO?


Yep, I'm fine with the shorter macro name.

May I install such a change?

Yes.
jeff



[PATCH] coroutines: Wrap awaiting if/swich in a BIND_EXPR, if needed [PR106188]

2022-09-03 Thread Arsen Arsenović via Gcc-patches
In the edge case of a coroutine not containing any locals, the ifcd/swch
temporaries would get added to the coroutine frame, corrupting its
layout. We can prevent this by ensuring that in cases where the scope of
the if/switch is the same as the coroutine frame one, we insert a
wrapping BIND_EXPR and try again.

PR c++/106188 - [coroutines] Incorrect frame layout after transforming 
conditional statement without top-level bind expression

PR c++/106713 - [11/12/13 Regression] Coroutine regression in GCC 11.3.0: if 
(co_await ...) crashes with a jump to ud2 since r12-3529-g70ee703c479081ac

gcc/cp/ChangeLog:
PR c++/106188
PR c++/106713
* coroutines.cc (struct susp_frame_data): Add fn_body for
  informing the await_statement_walker of the coroutine body.
(maybe_add_bind): New function.
(await_statement_walker): Call maybe_add_bind when necessary.
(morph_fn_to_coro): Pass fnbody into susp_frame_data.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr106188.C: New test.

Signed-off-by: Arsen Arsenović 
---
 gcc/cp/coroutines.cc   | 45 --
 gcc/testsuite/g++.dg/coroutines/pr106188.C | 35 +
 2 files changed, 77 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/coroutines/pr106188.C

diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index edb3b706ddc..2e88fb99d7d 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -2586,6 +2586,7 @@ struct susp_frame_data
   bool captures_temporary;  /* This expr captures temps by ref.  */
   bool needs_truth_if_exp;  /* We must expand a truth_if expression.  */
   bool has_awaiter_init;/* We must handle initializing an awaiter.  */
+  tree *fn_body;/* Original function body */
 };
 
 /* If this is an await expression, then count it (both uniquely within the
@@ -3326,6 +3327,33 @@ add_var_to_bind (tree& bind, tree var_type,
   return newvar;
 }
 
+/* Helper to ensure we have at least one bind to add vars to. */
+static bool
+maybe_add_bind(susp_frame_data *awpts, tree *stmt, location_t sloc)
+{
+  /* bind_stack is already asserted to be nonempty */
+  tree &bind = awpts->bind_stack->last();
+  gcc_checking_assert(TREE_CODE (*awpts->fn_body) == BIND_EXPR);
+  if (BIND_EXPR_VARS (bind) != BIND_EXPR_VARS (*awpts->fn_body))
+{
+  /* Alright, we have a unique (enough) scope, bail early. */
+  return false;
+}
+
+  /* In this case, we'd be pushing variables to the start of the coroutine
+   * unless we add a new BIND_EXPR here.
+   */
+  tree ifsw_bind = build3_loc (sloc, BIND_EXPR, void_type_node,
+NULL, NULL, NULL);
+  BIND_EXPR_BODY (ifsw_bind) = *stmt;
+  *stmt = ifsw_bind;
+  /* We don't push this BIND_EXPR to the walkers bind stack, it will be handled
+   * by a call to cp_walk_tree, since we start the next walk off from this
+   * bind node.
+   */
+  return true;
+}
+
 /* Helper to build and add if (!cond) break;  */
 
 static void
@@ -3456,6 +3484,12 @@ await_statement_walker (tree *stmt, int *do_subtree, 
void *d)
  return NULL_TREE; /* Nothing special to do here.  */
 
gcc_checking_assert (!awpts->bind_stack->is_empty());
+   location_t sloc = EXPR_LOCATION (IF_COND (if_stmt));
+   if (maybe_add_bind (awpts, stmt, sloc))
+  {
+   *do_subtree = false; /* Done inside maybe_add_bind. */
+   return cp_walk_tree (stmt, await_statement_walker, awpts, NULL);
+  }
tree& bind_expr = awpts->bind_stack->last ();
tree newvar = add_var_to_bind (bind_expr, boolean_type_node,
   "ifcd", awpts->cond_number++);
@@ -3464,7 +3498,6 @@ await_statement_walker (tree *stmt, int *do_subtree, void 
*d)
if (TREE_CODE (cond_inner) == CLEANUP_POINT_EXPR)
  cond_inner = TREE_OPERAND (cond_inner, 0);
add_decl_expr (newvar);
-   location_t sloc = EXPR_LOCATION (IF_COND (if_stmt));
/* We want to initialize the new variable with the expression
   that contains the await(s) and potentially also needs to
   have truth_if expressions expanded.  */
@@ -3640,6 +3673,12 @@ await_statement_walker (tree *stmt, int *do_subtree, 
void *d)
  return NULL_TREE; /* Nothing special to do here.  */
 
gcc_checking_assert (!awpts->bind_stack->is_empty());
+   location_t sloc = EXPR_LOCATION (SWITCH_STMT_COND (sw_stmt));
+   if (maybe_add_bind (awpts, stmt, sloc))
+  {
+   *do_subtree = false; /* Done inside maybe_add_bind. */
+   return cp_walk_tree (stmt, await_statement_walker, awpts, NULL);
+  }
/* Build a variable to hold the condition, this will be
   included in the frame as a local var.  */
tree& bind_expr = awpts->bind_stack->last ();

Re: [PATCH] LoongArch: add -mdirect-extern-access option

2022-09-03 Thread Fangrui Song via Gcc-patches
On Fri, Sep 2, 2022 at 4:31 AM Xi Ruoyao via Gcc-patches
 wrote:
>
> On Thu, 2022-09-01 at 18:54 +0800, Xi Ruoyao wrote:
> > We'd like to introduce a new codegen option to align with the old
> > "-Wa,-mla-global-with-pcrel" and avoid a performance & size regression
> > building the Linux kernel with new-reloc toolchain.  And it should be
> > also useful for building statically linked executables, firmwares (EDK2
> > for example), and other OS kernels.
>
> Some news: get rid of the GOT will also make the implementation of
> relocatable kernel easier, so I hope this can be reviewed quickly.
>
> > OK for trunk?
> >
> > -- >8 --
> >
> > As a new target, LoongArch does not use copy relocation as it's
> > problematic in some circumstances.  One bad consequence is we are
> > emitting GOT for all accesses to all extern objects with default
> > visibility.  The use of GOT is not needed in statically linked
> > executables, OS kernels etc.  The GOT entry just wastes space, and the
> > GOT access just slow down the execution in those environments.
> >
> > Before -mexplicit-relocs, we used "-Wa,-mla-global-with-pcrel" to tell
> > the assembler not to use GOT for extern access.  But with
> > -mexplicit-relocs, we have to opt the logic in GCC.
> >
> > The name "-mdirect-extern-access" is learnt from x86 port.

I think a discussion about the exact option name is useful.

The GCC x86 port generates
GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS for
-mno-direct-extern-access.

The Clang -fdirect-access-external-data (which is added before
-mdirect-extern-access) does not use
GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS.

If a new port avoids copy relocations in the first place,
GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS isn't really useful.

> > gcc/ChangeLog:
> >
> > * config/loongarch/genopts/loongarch.opt.in: Add
> > -mdirect-extern-access option.
> > * config/loongarch/loongarch.opt: Regenerate.
> > * config/loongarch/loongarch.cc (loongarch_classify_symbol):
> > Don't use SYMBOL_GOT_DISP if TARGET_DIRECT_EXTERN_ACCESS.
> > (loongarch_option_override_internal): Complain if
> > -mdirect-extern-access is used with -fPIC or -fpic.
> > * doc/invoke.texi: Document -mdirect-extern-access for
> > LoongArch.
> >
> > gcc/testsuite/ChangeLog:
> >
> > * gcc.target/loongarch/direct-extern-1.c: New test.
> > * gcc.target/loongarch/direct-extern-2.c: New test.
> > ---
> >  gcc/config/loongarch/genopts/loongarch.opt.in |  4 
> >  gcc/config/loongarch/loongarch.cc |  5 -
> >  gcc/config/loongarch/loongarch.opt|  4 
> >  gcc/doc/invoke.texi   | 15
> > +++
> >  .../gcc.target/loongarch/direct-extern-1.c|  6 ++
> >  .../gcc.target/loongarch/direct-extern-2.c|  6 ++
> >  6 files changed, 39 insertions(+), 1 deletion(-)
> >  create mode 100644 gcc/testsuite/gcc.target/loongarch/direct-extern-
> > 1.c
> >  create mode 100644 gcc/testsuite/gcc.target/loongarch/direct-extern-
> > 2.c
> >
> > diff --git a/gcc/config/loongarch/genopts/loongarch.opt.in
> > b/gcc/config/loongarch/genopts/loongarch.opt.in
> > index ebdd9538d48..e10618777b2 100644
> > --- a/gcc/config/loongarch/genopts/loongarch.opt.in
> > +++ b/gcc/config/loongarch/genopts/loongarch.opt.in
> > @@ -184,3 +184,7 @@ Enum(cmodel) String(@@STR_CMODEL_EXTREME@@)
> > Value(CMODEL_EXTREME)
> >  mcmodel=
> >  Target RejectNegative Joined Enum(cmodel) Var(la_opt_cmodel)
> > Init(CMODEL_NORMAL)
> >  Specify the code model.
> > +
> > +mdirect-extern-access
> > +Target Var(TARGET_DIRECT_EXTERN_ACCESS) Init(0)
> > +Avoid using the GOT to access external symbols.
> > diff --git a/gcc/config/loongarch/loongarch.cc
> > b/gcc/config/loongarch/loongarch.cc
> > index 77e3a105390..2875fa5b0f3 100644
> > --- a/gcc/config/loongarch/loongarch.cc
> > +++ b/gcc/config/loongarch/loongarch.cc
> > @@ -1642,7 +1642,7 @@ loongarch_classify_symbol (const_rtx x)
> >if (SYMBOL_REF_TLS_MODEL (x))
> >  return SYMBOL_TLS;
> >
> > -  if (!loongarch_symbol_binds_local_p (x))
> > +  if (!TARGET_DIRECT_EXTERN_ACCESS && !loongarch_symbol_binds_local_p
> > (x))
> >  return SYMBOL_GOT_DISP;
> >
> >tree t = SYMBOL_REF_DECL (x);
> > @@ -6093,6 +6093,9 @@ loongarch_option_override_internal (struct
> > gcc_options *opts)
> >if (loongarch_branch_cost == 0)
> >  loongarch_branch_cost = loongarch_cost->branch_cost;
> >
> > +  if (TARGET_DIRECT_EXTERN_ACCESS && flag_shlib)
> > +error ("%qs cannot be used for compiling a shared library",
> > +  "-mdirect-extern-access");
> >
> >switch (la_target.cmodel)
> >  {
> > diff --git a/gcc/config/loongarch/loongarch.opt
> > b/gcc/config/loongarch/loongarch.opt
> > index 6395234218b..96c811c850b 100644
> > --- a/gcc/config/loongarch/loongarch.opt
> > +++ b/gcc/config/loongarch/loongarch.opt
> > @@ -191,3 +191,7 @@ Enum(cmodel) String(extreme) Value(CMOD

Re: [PATCH] LoongArch: add -mdirect-extern-access option

2022-09-03 Thread Lulu Cheng

I think the following modification should be added:

git diff loongarch/predicates.md

+;; Do not use GOT to access external symbols, when define
+;; TARGET_DIRECT_EXTERN_ACCESS.
+
 (define_predicate "is_const_call_local_symbol"
   (and (match_operand 0 "const_call_insn_operand")
    (ior (match_test "loongarch_global_symbol_p (op) == 0")
-   (match_test "loongarch_symbol_binds_local_p (op) != 0"))
+   (match_test "loongarch_symbol_binds_local_p (op) != 0")
+   (match_test "loongarch_symbol_binds_local_p (op) == 0
+    && TARGET_DIRECT_EXTERN_ACCESS"))
    (match_test "CONSTANT_P (op)")))

 (define_predicate "is_const_call_no_local_symbol"
   (and (match_operand 0 "const_call_insn_operand")
    (ior (match_test "loongarch_global_symbol_p (op) != 0")
    (match_test "loongarch_symbol_binds_local_p (op) == 0")
-   (match_test "loongarch_weak_symbol_p (op) != 0"))
+   (match_test "loongarch_weak_symbol_p (op) != 0")
+   (match_test "!TARGET_DIRECT_EXTERN_ACCESS"))
    (match_test "CONSTANT_P (op)")))


testsuites:

extern void test1(void);

void

test(void)
{
  test1();
}

$ gcc test.c -o - -O2 -mdirect-extern-access

If the above modifications are not added, the function call is:  bl 
%plt(test1) now is : bl test1 在 2022/9/2 下午7:30, Xi Ruoyao 写道:



On Thu, 2022-09-01 at 18:54 +0800, Xi Ruoyao wrote:

We'd like to introduce a new codegen option to align with the old
"-Wa,-mla-global-with-pcrel" and avoid a performance & size regression
building the Linux kernel with new-reloc toolchain.  And it should be
also useful for building statically linked executables, firmwares (EDK2
for example), and other OS kernels.

Some news: get rid of the GOT will also make the implementation of
relocatable kernel easier, so I hope this can be reviewed quickly.


OK for trunk?

-- >8 --

As a new target, LoongArch does not use copy relocation as it's
problematic in some circumstances.  One bad consequence is we are
emitting GOT for all accesses to all extern objects with default
visibility.  The use of GOT is not needed in statically linked
executables, OS kernels etc.  The GOT entry just wastes space, and the
GOT access just slow down the execution in those environments.

Before -mexplicit-relocs, we used "-Wa,-mla-global-with-pcrel" to tell
the assembler not to use GOT for extern access.  But with
-mexplicit-relocs, we have to opt the logic in GCC.

The name "-mdirect-extern-access" is learnt from x86 port.

gcc/ChangeLog:

 * config/loongarch/genopts/loongarch.opt.in: Add
 -mdirect-extern-access option.
 * config/loongarch/loongarch.opt: Regenerate.
 * config/loongarch/loongarch.cc (loongarch_classify_symbol):
 Don't use SYMBOL_GOT_DISP if TARGET_DIRECT_EXTERN_ACCESS.
 (loongarch_option_override_internal): Complain if
 -mdirect-extern-access is used with -fPIC or -fpic.
 * doc/invoke.texi: Document -mdirect-extern-access for
 LoongArch.

gcc/testsuite/ChangeLog:

 * gcc.target/loongarch/direct-extern-1.c: New test.
 * gcc.target/loongarch/direct-extern-2.c: New test.
---
  gcc/config/loongarch/genopts/loongarch.opt.in |  4 
  gcc/config/loongarch/loongarch.cc |  5 -
  gcc/config/loongarch/loongarch.opt    |  4 
  gcc/doc/invoke.texi   | 15
+++
  .../gcc.target/loongarch/direct-extern-1.c    |  6 ++
  .../gcc.target/loongarch/direct-extern-2.c    |  6 ++
  6 files changed, 39 insertions(+), 1 deletion(-)
  create mode 100644 gcc/testsuite/gcc.target/loongarch/direct-extern-
1.c
  create mode 100644 gcc/testsuite/gcc.target/loongarch/direct-extern-
2.c

diff --git a/gcc/config/loongarch/genopts/loongarch.opt.in
b/gcc/config/loongarch/genopts/loongarch.opt.in
index ebdd9538d48..e10618777b2 100644
--- a/gcc/config/loongarch/genopts/loongarch.opt.in
+++ b/gcc/config/loongarch/genopts/loongarch.opt.in
@@ -184,3 +184,7 @@ Enum(cmodel) String(@@STR_CMODEL_EXTREME@@)
Value(CMODEL_EXTREME)
  mcmodel=
  Target RejectNegative Joined Enum(cmodel) Var(la_opt_cmodel)
Init(CMODEL_NORMAL)
  Specify the code model.
+
+mdirect-extern-access
+Target Var(TARGET_DIRECT_EXTERN_ACCESS) Init(0)
+Avoid using the GOT to access external symbols.
diff --git a/gcc/config/loongarch/loongarch.cc
b/gcc/config/loongarch/loongarch.cc
index 77e3a105390..2875fa5b0f3 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -1642,7 +1642,7 @@ loongarch_classify_symbol (const_rtx x)
    if (SYMBOL_REF_TLS_MODEL (x))
  return SYMBOL_TLS;
  
-  if (!loongarch_symbol_binds_local_p (x))

+  if (!TARGET_DIRECT_EXTERN_ACCESS && !loongarch_symbol_binds_local_p
(x))
  return SYMBOL_GOT_DISP;
  
    tree t = SYMBOL_REF_DECL (x);

@@ -6093,6 +6093,9 @@ loongarch_option_override_internal (struct
gcc_options *opts)
    if (loongarch_branch_cost == 0)
  loonga

Re: [PATCH] LoongArch: add -mdirect-extern-access option

2022-09-03 Thread Xi Ruoyao via Gcc-patches
On Sun, 2022-09-04 at 10:26 +0800, Lulu Cheng wrote:
> If the above modifications are not added, the function call is:
> 
>  bl %plt(test1)
> 
> now is :
> 
>  bl test1

Regarding "%plt(...)", in the binutils code:

   /* For compatible old asm code.  */
   if (0 == strcmp (op_c_str, "plt"))
 btype = BFD_RELOC_LARCH_B26;

Link: 
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gas/config/loongarch-parse.y;h=8704687706df50aa15aff05f97e4560d7ec6fa23;hb=refs/heads/master#l131

Zhensong: does "old asm code" here mean we should remove %plt from "new"
assembly code, i. e. stop to print %plt(...) in GCC completely?

-- 
Xi Ruoyao 
School of Aerospace Science and Technology, Xidian University


Re: [PATCH] LoongArch: add -mdirect-extern-access option

2022-09-03 Thread Lulu Cheng



在 2022/9/4 上午10:51, Xi Ruoyao 写道:

On Sun, 2022-09-04 at 10:26 +0800, Lulu Cheng wrote:

If the above modifications are not added, the function call is:

  bl %plt(test1)

now is :

  bl test1

Regarding "%plt(...)", in the binutils code:

/* For compatible old asm code.  */
if (0 == strcmp (op_c_str, "plt"))
  btype = BFD_RELOC_LARCH_B26;

Link: 
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gas/config/loongarch-parse.y;h=8704687706df50aa15aff05f97e4560d7ec6fa23;hb=refs/heads/master#l131

Zhensong: does "old asm code" here mean we should remove %plt from "new"
assembly code, i. e. stop to print %plt(...) in GCC completely?



I think '%plt' also needs to be removed from the readability of the 
assembly code.:-\




Re: [PATCH] LoongArch: add -mdirect-extern-access option

2022-09-03 Thread Xi Ruoyao via Gcc-patches
On Sun, 2022-09-04 at 11:22 +0800, Lulu Cheng wrote:
> 
> 在 2022/9/4 上午10:51, Xi Ruoyao 写道:
>  
> > On Sun, 2022-09-04 at 10:26 +0800, Lulu Cheng wrote:
> >  
> > > If the above modifications are not added, the function call is:
> > > 
> > >  bl %plt(test1)
> > > 
> > > now is :
> > > 
> > >  bl test1
> > Regarding "%plt(...)", in the binutils code:
> > 
> >    /* For compatible old asm code.  */
> >    if (0 == strcmp (op_c_str, "plt"))
> >  btype = BFD_RELOC_LARCH_B26;
> > 
> > Link:
> > https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gas/config/loongarch-parse.y;h=8704687706df50aa15aff05f97e4560d7ec6fa23;hb=refs/heads/master#l131
> > 
> > Zhensong: does "old asm code" here mean we should remove %plt from
> > "new"
> > assembly code, i. e. stop to print %plt(...) in GCC completely?
> > 
>  
> I think '%plt' also needs to be removed from the readability of the
> assembly code.:-\

I understand, but maybe we should remove %plt unconditionally, with or
without -mdirect-extern-access.  Note that for -mcmodel=medium we don't
say something like "%pc_hi20(%plt(x))" either.
-- 
Xi Ruoyao 
School of Aerospace Science and Technology, Xidian University