]> gcc.gnu.org Git - gcc.git/log
gcc.git
10 months agoRISC-V: Add VLS widen binary combine patterns
Juzhe-Zhong [Fri, 22 Sep 2023 10:07:20 +0000 (18:07 +0800)]
RISC-V: Add VLS widen binary combine patterns

Regression passed.

Committed.

gcc/ChangeLog:

* config/riscv/vector-iterators.md: Extend VLS modes.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/def.h: Add VLS modes cond tests.
* gcc.target/riscv/rvv/autovec/vls/wadd-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/wadd-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/wadd-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls/wadd-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls/wmul-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/wmul-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/wmul-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls/wsub-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/wsub-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/wsub-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls/wsub-4.c: New test.

10 months agoc++: missing SFINAE in grok_array_decl [PR111493]
Patrick Palka [Fri, 22 Sep 2023 10:27:48 +0000 (06:27 -0400)]
c++: missing SFINAE in grok_array_decl [PR111493]

We should guard both the diagnostic and backward compatibilty fallback
code with tf_error, so that in a SFINAE context we don't issue any
diagnostics and correctly treat ill-formed C++23 multidimensional
subscript operator expressions as such.

PR c++/111493

gcc/cp/ChangeLog:

* decl2.cc (grok_array_decl): Guard diagnostic and backward
compatibility fallback code paths with tf_error.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/subscript15.C: New test.

10 months agoc++: constraint rewriting during ttp coercion [PR111485]
Patrick Palka [Fri, 22 Sep 2023 10:25:49 +0000 (06:25 -0400)]
c++: constraint rewriting during ttp coercion [PR111485]

In order to compare the constraints of a ttp with that of its argument,
we rewrite the ttp's constraints in terms of the argument template's
template parameters.  The substitution to achieve this currently uses a
single level of template arguments, but that never does the right thing
because a ttp's template parameters always have level >= 2.  This patch
fixes this by including the outer template arguments in the substitution,
which ought to match the depth of the ttp.

The second testcase demonstrates it's better to substitute the concrete
outer template arguments instead of generic ones since a ttp's constraints
could depend on outer parameters.

PR c++/111485

gcc/cp/ChangeLog:

* pt.cc (is_compatible_template_arg): New parameter 'args'.
Add the outer template arguments 'args' to 'new_args'.
(convert_template_argument): Pass 'args' to
is_compatible_template_arg.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-ttp5.C: New test.
* g++.dg/cpp2a/concepts-ttp6.C: New test.

10 months agoRISC-V: Move ceil test cases to unop folder
Pan Li [Fri, 22 Sep 2023 09:10:42 +0000 (17:10 +0800)]
RISC-V: Move ceil test cases to unop folder

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/math-ceil-0.c: Moved to...
* gcc.target/riscv/rvv/autovec/unop/math-ceil-0.c: ...here.
* gcc.target/riscv/rvv/autovec/math-ceil-1.c: Moved to...
* gcc.target/riscv/rvv/autovec/unop/math-ceil-1.c: ...here.
* gcc.target/riscv/rvv/autovec/math-ceil-2.c: Moved to...
* gcc.target/riscv/rvv/autovec/unop/math-ceil-2.c: ...here.
* gcc.target/riscv/rvv/autovec/math-ceil-3.c: Moved to...
* gcc.target/riscv/rvv/autovec/unop/math-ceil-3.c: ...here.
* gcc.target/riscv/rvv/autovec/math-ceil-run-0.c: Moved to...
* gcc.target/riscv/rvv/autovec/unop/math-ceil-run-0.c: ...here.
* gcc.target/riscv/rvv/autovec/math-ceil-run-1.c: Moved to...
* gcc.target/riscv/rvv/autovec/unop/math-ceil-run-1.c: ...here.
* gcc.target/riscv/rvv/autovec/math-ceil-run-2.c: Moved to...
* gcc.target/riscv/rvv/autovec/unop/math-ceil-run-2.c: ...here.
* gcc.target/riscv/rvv/autovec/test-math.h: Moved to...
* gcc.target/riscv/rvv/autovec/unop/test-math.h: ...here.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agoRISC-V: Remove @ of vec_duplicate pattern
Juzhe-Zhong [Fri, 22 Sep 2023 08:28:46 +0000 (16:28 +0800)]
RISC-V: Remove @ of vec_duplicate pattern

It's obvious the @ of vec_duplicate pattern is duplicate.

Regression passed.

Committed.
gcc/ChangeLog:

* config/riscv/riscv-v.cc (gen_const_vector_dup): Use global expand function.
* config/riscv/vector.md (@vec_duplicate<mode>): Remove @.
(vec_duplicate<mode>): Ditto.

10 months agoRISC-V: Add VLS conditional patterns support
Juzhe-Zhong [Fri, 22 Sep 2023 03:44:49 +0000 (11:44 +0800)]
RISC-V: Add VLS conditional patterns support

Regression passed.

Committed.

gcc/ChangeLog:

* config/riscv/autovec.md: Add VLS conditional patterns.
* config/riscv/riscv-protos.h (expand_cond_unop): Ditto.
(expand_cond_binop): Ditto.
(expand_cond_ternop): Ditto.
* config/riscv/riscv-v.cc (expand_cond_unop): Ditto.
(expand_cond_binop): Ditto.
(expand_cond_ternop): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/def.h: Add VLS conditional tests.
* gcc.target/riscv/rvv/autovec/vls/cond_add-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_add-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_and-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_div-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_div-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_fma-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_fma-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_fms-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_fnma-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_fnma-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_fnms-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_ior-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_max-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_max-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_min-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_min-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_mod-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_mul-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_mul-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_neg-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_neg-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_not-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_shift-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_shift-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_sub-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_sub-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/cond_xor-1.c: New test.

10 months agoRISC-V: Rename the test macro for math autovec test
Pan Li [Fri, 22 Sep 2023 03:44:01 +0000 (11:44 +0800)]
RISC-V: Rename the test macro for math autovec test

Rename TEST_CEIL to TEST_UNARY_CALL for the underlying function
autovec patch testing.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/test-math.h: Rename.
* gcc.target/riscv/rvv/autovec/math-ceil-0.c: Ditto.
* gcc.target/riscv/rvv/autovec/math-ceil-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/math-ceil-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/math-ceil-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/math-ceil-run-0.c: Ditto.
* gcc.target/riscv/rvv/autovec/math-ceil-run-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/math-ceil-run-2.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agoRISC-V: Optimization of vrgather.vv into vrgatherei16.vv[PR111451]
xuli [Fri, 22 Sep 2023 01:25:39 +0000 (01:25 +0000)]
RISC-V: Optimization of vrgather.vv into vrgatherei16.vv[PR111451]

Consider this following case:

typedef int32_t vnx32si __attribute__ ((vector_size (128)));

  __attribute__ ((noipa)) void permute_##TYPE (TYPE values1, TYPE values2,     \
       TYPE *out)                      \
  {                                                                            \
    TYPE v                                                                     \
      = __builtin_shufflevector (values1, values2, MASK_##NUNITS (0, NUNITS)); \
    *(TYPE *) out = v;                                                         \
  }

  T (vnx32si, 32)                                                              \

TEST_ALL (PERMUTE)

Before this patch:
  li a4,31
  vsetvli a5,zero,e32,m8,ta,ma
  vl8re32.v v24,0(a0)
  vid.v v8
  vrsub.vx v8,v8,a4
  vrgather.vv v16,v24,v8
  vs8r.v v16,0(a2)
  ret

The index vector register "v8" occupies 8 registers.
We should optimize it into vrgatherei16.vv which is
using int16 as the index elements.

After this patch:
  vsetvli a5,zero,e16,m4,ta,ma
  li a4,31
  vid.v v4
  vl8re32.v v16,0(a0)
  vrsub.vx v4,v4,a4
  vsetvli zero,zero,e32,m8,ta,ma
  vrgatherei16.vv v8,v16,v4
  vs8r.v v8,0(a2)
  ret
With vrgatherei16.vv, the v8 will occupy 4 registers instead
of 8. Lower the register consuming and register pressure.

PR target/111451

gcc/ChangeLog:

* config/riscv/riscv-v.cc (emit_vlmax_gather_insn): Optimization of vrgather.vv
into vrgatherei16.vv.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls-vlmax/perm-4.c: Adjust case.
* gcc.target/riscv/rvv/autovec/vls/perm-4.c: Ditto.

10 months agoRISC-V: Remove arch and abi option for run test case.
Pan Li [Fri, 22 Sep 2023 03:38:11 +0000 (11:38 +0800)]
RISC-V: Remove arch and abi option for run test case.

Remove the -march and -mabi.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/math-ceil-run-0.c: Remove arch and abi.
* gcc.target/riscv/rvv/autovec/math-ceil-run-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/math-ceil-run-2.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agoRISC-V: Support combine cond extend and reduce sum to widen reduce sum
Lehua Ding [Fri, 22 Sep 2023 01:44:03 +0000 (09:44 +0800)]
RISC-V: Support combine cond extend and reduce sum to widen reduce sum

This patch support combining cond extend and reduce_sum to cond widen reduce_sum
like combine the following three insns:
   (set (reg:RVVM2HI 149)
        (if_then_else:RVVM2HI
          (unspec:RVVMF8BI [
            (const_vector:RVVMF8BI repeat [
              (const_int 1 [0x1])
            ])
            (reg:DI 146)
            (const_int 2 [0x2]) repeated x2
            (const_int 1 [0x1])
            (reg:SI 66 vl)
            (reg:SI 67 vtype)
          ] UNSPEC_VPREDICATE)
         (const_vector:RVVM2HI repeat [
           (const_int 0 [0])
         ])
         (unspec:RVVM2HI [
           (reg:SI 0 zero)
         ] UNSPEC_VUNDEF)))
  (set (reg:RVVM2HI 138)
    (if_then_else:RVVM2HI
      (reg:RVVMF8BI 135)
      (reg:RVVM2HI 148)
      (reg:RVVM2HI 149)))
  (set (reg:HI 150)
    (unspec:HI [
      (reg:RVVM2HI 138)
    ] UNSPEC_REDUC_SUM))
into one insn:
  (set (reg:SI 147)
    (unspec:SI [
      (if_then_else:RVVM2SI
        (reg:RVVMF16BI 135)
        (sign_extend:RVVM2SI (reg:RVVM1HI 136))
        (if_then_else:RVVM2HI
          (unspec:RVVMF8BI [
            (const_vector:RVVMF8BI repeat [
              (const_int 1 [0x1])
            ])
            (reg:DI 146)
            (const_int 2 [0x2]) repeated x2
            (const_int 1 [0x1])
            (reg:SI 66 vl)
            (reg:SI 67 vtype)
          ] UNSPEC_VPREDICATE)
         (const_vector:RVVM2HI repeat [
           (const_int 0 [0])
         ])
         (unspec:RVVM2HI [
           (reg:SI 0 zero)
         ] UNSPEC_VUNDEF)))
    ] UNSPEC_REDUC_SUM))

Consider the following C code:

int16_t foo (int8_t *restrict a, int8_t *restrict pred)
{
  int16_t sum = 0;
  for (int i = 0; i < 16; i += 1)
    if (pred[i])
      sum += a[i];
  return sum;
}

assembly before this patch:

foo:
        vsetivli        zero,16,e16,m2,ta,ma
        li      a5,0
        vmv.v.i v2,0
        vsetvli zero,zero,e8,m1,ta,ma
        vl1re8.v        v0,0(a1)
        vmsne.vi        v0,v0,0
        vsetvli zero,zero,e16,m2,ta,mu
        vle8.v  v4,0(a0),v0.t
        vmv.s.x v1,a5
        vsext.vf2       v2,v4,v0.t
        vredsum.vs      v2,v2,v1
        vmv.x.s a0,v2
        slliw   a0,a0,16
        sraiw   a0,a0,16
        ret

assembly after this patch:

foo:
li a5,0
vsetivli zero,16,e16,m1,ta,ma
vmv.s.x v3,a5
vsetivli zero,16,e8,m1,ta,ma
vl1re8.v v0,0(a1)
vmsne.vi v0,v0,0
vle8.v v2,0(a0),v0.t
vwredsum.vs v1,v2,v3,v0.t
vsetivli zero,0,e16,m1,ta,ma
vmv.x.s a0,v1
slliw a0,a0,16
sraiw a0,a0,16
ret

gcc/ChangeLog:

* config/riscv/autovec-opt.md (*cond_widen_reduc_plus_scal_<mode>):
New combine patterns.
* config/riscv/riscv-protos.h (enum insn_type): New insn_type.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-1.c: New test.
* gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c: New test.
* gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc_run-1.c: New test.
* gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc_run-2.c: New test.

10 months agoRISC-V: Split VLS avl_type from NONVLMAX avl_type
Lehua Ding [Fri, 22 Sep 2023 01:43:10 +0000 (09:43 +0800)]
RISC-V: Split VLS avl_type from NONVLMAX avl_type

This patch split a VLS avl_type from the NONVLMAX avl_type, denoting
those RVV insn with length set to the number of units of VLS modes.

gcc/ChangeLog:

* config/riscv/riscv-protos.h (enum avl_type): New VLS avl_type.
* config/riscv/riscv-v.cc (autovec_use_vlmax_p): Move comments.

10 months agoRISC-V: Leverage __builtin_xx instead of math.h for test
Pan Li [Fri, 22 Sep 2023 01:09:34 +0000 (09:09 +0800)]
RISC-V: Leverage __builtin_xx instead of math.h for test

The math.h may have problems in some environment, take __builtin__xx
instead for testing.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/floating-point-max-5.c:
Remove reference to math.h.
* gcc.target/riscv/rvv/autovec/vls/floating-point-min-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/floating-point-sgnjx-2.c: Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agoRISC-V: Support ceil and ceilf auto-vectorization
Pan Li [Wed, 20 Sep 2023 01:36:22 +0000 (09:36 +0800)]
RISC-V: Support ceil and ceilf auto-vectorization

Update in v4:

* Add test for _Float16.
* Remove unnecessary macro in def.h for test.

Original log:

This patch would like to support auto-vectorization for both the
ceil and ceilf of math.h. It depends on the -ffast-math option.

When we would like to call ceil/ceilf like v2 = ceil (v1), we will
convert it into below insn (reference the implementation of llvm).

* vfcvt.x.f v3, v1, RUP
* vfcvt.f.x v2, v3

However, the floating point value may not need the cvt as above if
its mantissa is zero. For example single precision floating point below.

  +-----------+---------------+
  | float     | binary layout |
  +-----------+---------------+
  | 8388607.5 | 0x4affffff    |
  | 8388608.0 | 0x4b000000    |
  | 8388609.0 | 0x4b000001    |
  +-----------+---------------+

All single floating point great than 8388608.0 will have all zero mantisaa.
We leverage vmflt and mask to filter them out in vector and only do the
cvt on mask.

Befor this patch:
math-ceil-1.c:21:1: missed: couldn't vectorize loop
  ...
.L3:
  flw     fa0,0(s0)
  addi    s0,s0,4
  addi    s1,s1,4
  call    ceilf
  fsw     fa0,-4(s1)
  bne     s0,s2,.L3

After this patch:
  ...
  fsrmi   3
.L4:
  vfabs.v     v0,v1
  vmv1r.v     v2,v1
  vmflt.vv    v0,v0,v4
  sub         a3,a3,a4
  vfcvt.x.f.v v3,v1,v0.t
  vfcvt.f.x.v v2,v3,v0.t
  vfsgnj.vv   v2,v2,v1
  bne         .L4
.L14:
  fsrm    a6
  ret

Please note VLS mode is also involved in this patch and covered by the
test cases.

gcc/ChangeLog:

* config/riscv/autovec.md (ceil<mode>2): New pattern.
* config/riscv/riscv-protos.h (enum insn_flags): New enum type.
(enum insn_type): Ditto.
(expand_vec_ceil): New function decl.
* config/riscv/riscv-v.cc (gen_ceil_const_fp): New function impl.
(expand_vec_float_cmp_mask): Ditto.
(expand_vec_copysign): Ditto.
(expand_vec_ceil): Ditto.
* config/riscv/vector.md: Add VLS mode support.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/math-ceil-0.c: New test.
* gcc.target/riscv/rvv/autovec/math-ceil-1.c: New test.
* gcc.target/riscv/rvv/autovec/math-ceil-2.c: New test.
* gcc.target/riscv/rvv/autovec/math-ceil-3.c: New test.
* gcc.target/riscv/rvv/autovec/math-ceil-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/math-ceil-run-1.c: New test.
* gcc.target/riscv/rvv/autovec/math-ceil-run-2.c: New test.
* gcc.target/riscv/rvv/autovec/test-math.h: New test.
* gcc.target/riscv/rvv/autovec/vls/math-ceil-1.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
10 months agoDaily bump.
GCC Administrator [Fri, 22 Sep 2023 00:17:39 +0000 (00:17 +0000)]
Daily bump.

10 months agoRISC-V: Add VLS integer ABS support
Juzhe-Zhong [Thu, 21 Sep 2023 22:47:22 +0000 (06:47 +0800)]
RISC-V: Add VLS integer ABS support

Regression passed.

Committed.

gcc/ChangeLog:

* config/riscv/autovec.md: Extend VLS modes.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/abs-2.c: New test.

10 months agoRISC-V: Add more VLS unary tests
Juzhe-Zhong [Thu, 21 Sep 2023 12:33:33 +0000 (20:33 +0800)]
RISC-V: Add more VLS unary tests

Notice we are missing these tests.

Committed.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/abs-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/not-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/sqrt-1.c: New test.

10 months agoRISC-V: Support VLS mult high
Juzhe-Zhong [Thu, 21 Sep 2023 11:54:10 +0000 (19:54 +0800)]
RISC-V: Support VLS mult high

Regression passed.

Committed.

gcc/ChangeLog:

* config/riscv/vector-iterators.md: Extend VLS modes.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/def.h: Add VLS mult high.
* gcc.target/riscv/rvv/autovec/vls/mulh-1.c: New test.

10 months agoRISC-V: Adjusting the comments of the emit_vlmax_insn/emit_vlmax_insn_lra/emit_nonvlm...
Lehua Ding [Thu, 21 Sep 2023 07:02:32 +0000 (15:02 +0800)]
RISC-V: Adjusting the comments of the emit_vlmax_insn/emit_vlmax_insn_lra/emit_nonvlmax_insn functions

V2 Change: Use Robin's comments.

This patch adjusts the comments of the
emit_vlmax_insn/emit_vlmax_insn_lra/emit_nonvlmax_insn functions.
The purpose of the adjustment is to make it clear that vlmax here is not
VLMAX as defined inside the RVV ISA. This is because this function is used
by RVV mode (e.g. RVVM1SImode) in addition to VLS mode (V16QI). For RVV mode,
it means the same thing, for VLS mode, it indicates setting the vl to the
number of units of the mode. Changed the comment because I didn't think of
a better name. If there is a suitable name, feel free to discuss it.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (emit_vlmax_insn): Adjust comments.
(emit_nonvlmax_insn): Adjust comments.
(emit_vlmax_insn_lra): Adjust comments.

Co-Authored-By: Robin Dapp <rdapp.gcc@gmail.com>
10 months agorust: Implement TARGET_RUST_OS_INFO for *-*-*linux*.
Iain Buclaw [Thu, 13 Oct 2022 14:42:23 +0000 (16:42 +0200)]
rust: Implement TARGET_RUST_OS_INFO for *-*-*linux*.

gcc/ChangeLog:

* config.gcc (*linux*): Set rust target_objs, and
target_has_targetrustm,
* config/t-linux (linux-rust.o): New rule.
* config/linux-rust.cc: New file.

10 months agorust: Implement TARGET_RUST_OS_INFO for i[34567]86-*-mingw* and x86_64-*-mingw*.
Iain Buclaw [Thu, 13 Oct 2022 14:38:21 +0000 (16:38 +0200)]
rust: Implement TARGET_RUST_OS_INFO for i[34567]86-*-mingw* and x86_64-*-mingw*.

gcc/ChangeLog:

* config.gcc (i[34567]86-*-mingw* | x86_64-*-mingw*): Set
rust_target_objs and target_has_targetrustm.
* config/t-winnt (winnt-rust.o): New rule.
* config/winnt-rust.cc: New file.

10 months agorust: Implement TARGET_RUST_OS_INFO for *-*-fuchsia*.
Iain Buclaw [Thu, 13 Oct 2022 12:51:17 +0000 (14:51 +0200)]
rust: Implement TARGET_RUST_OS_INFO for *-*-fuchsia*.

gcc/ChangeLog:

* config.gcc (*-*-fuchsia): Set tmake_rule, rust_target_objs,
and target_has_targetrustm.
* config/fuchsia-rust.cc: New file.
* config/t-fuchsia: New file.

10 months agorust: Implement TARGET_RUST_OS_INFO for *-*-vxworks*
Iain Buclaw [Thu, 13 Oct 2022 12:40:34 +0000 (14:40 +0200)]
rust: Implement TARGET_RUST_OS_INFO for *-*-vxworks*

gcc/ChangeLog:

* config.gcc (*-*-vxworks*): Set rust_target_objs and
target_has_targetrustm.
* config/t-vxworks (vxworks-rust.o): New rule.
* config/vxworks-rust.cc: New file.

10 months agorust: Implement TARGET_RUST_OS_INFO for *-*-dragonfly*
Iain Buclaw [Thu, 13 Oct 2022 08:12:44 +0000 (10:12 +0200)]
rust: Implement TARGET_RUST_OS_INFO for *-*-dragonfly*

gcc/ChangeLog:

* config.gcc (*-*-dragonfly*): Set rust_target_objs and
target_has_targetrustm.
* config/t-dragonfly (dragonfly-rust.o): New rule.
* config/dragonfly-rust.cc: New file.

10 months agorust: Implement TARGET_RUST_OS_INFO for *-*-solaris2*.
Iain Buclaw [Thu, 13 Oct 2022 08:06:42 +0000 (10:06 +0200)]
rust: Implement TARGET_RUST_OS_INFO for *-*-solaris2*.

gcc/ChangeLog:

* config.gcc (*-*-solaris2*): Set rust_target_objs and
target_has_targetrustm.
* config/t-sol2 (sol2-rust.o): New rule.
* config/sol2-rust.cc: New file.

10 months agorust: Implement TARGET_RUST_OS_INFO for *-*-openbsd*
Iain Buclaw [Thu, 13 Oct 2022 07:56:46 +0000 (09:56 +0200)]
rust: Implement TARGET_RUST_OS_INFO for *-*-openbsd*

gcc/ChangeLog:

* config.gcc (*-*-openbsd*): Set rust_target_objs and
target_has_targetrustm.
* config/t-openbsd (openbsd-rust.o): New rule.
* config/openbsd-rust.cc: New file.

10 months agorust: Implement TARGET_RUST_OS_INFO for *-*-netbsd*
Iain Buclaw [Thu, 13 Oct 2022 07:48:09 +0000 (09:48 +0200)]
rust: Implement TARGET_RUST_OS_INFO for *-*-netbsd*

gcc/ChangeLog:

* config.gcc (*-*-netbsd*): Set rust_target_objs and
target_has_targetrustm.
* config/t-netbsd (netbsd-rust.o): New rule.
* config/netbsd-rust.cc: New file.

10 months agorust: Implement TARGET_RUST_OS_INFO for *-*-freebsd*
Iain Buclaw [Thu, 13 Oct 2022 07:37:40 +0000 (09:37 +0200)]
rust: Implement TARGET_RUST_OS_INFO for *-*-freebsd*

gcc/ChangeLog:

* config.gcc (*-*-freebsd*): Set rust_target_objs and
target_has_targetrustm.
* config/t-freebsd (freebsd-rust.o): New rule.
* config/freebsd-rust.cc: New file.

10 months agorust: Implement TARGET_RUST_OS_INFO for *-*-darwin*
Iain Buclaw [Thu, 29 Sep 2022 08:30:42 +0000 (10:30 +0200)]
rust: Implement TARGET_RUST_OS_INFO for *-*-darwin*

gcc/ChangeLog:

* config.gcc (*-*-darwin*): Set rust_target_objs and
target_has_targetrustm.
* config/t-darwin (darwin-rust.o): New rule.
* config/darwin-rust.cc: New file.

10 months agorust: Implement TARGET_RUST_CPU_INFO for i[34567]86-*-* and x86_64-*-*
Iain Buclaw [Thu, 29 Sep 2022 08:34:18 +0000 (10:34 +0200)]
rust: Implement TARGET_RUST_CPU_INFO for i[34567]86-*-* and x86_64-*-*

There are still quite a lot of the previously reverted i386-rust.cc
missing, so it's only a partial reimplementation.

gcc/ChangeLog:

* config/i386/t-i386 (i386-rust.o): New rule.
* config/i386/i386-rust.cc: New file.
* config/i386/i386-rust.h: New file.

10 months agorust: Reintroduce TARGET_RUST_OS_INFO hook
Iain Buclaw [Wed, 28 Sep 2022 13:33:41 +0000 (15:33 +0200)]
rust: Reintroduce TARGET_RUST_OS_INFO hook

gcc/ChangeLog:

* doc/tm.texi: Regenerate.
* doc/tm.texi.in: Document TARGET_RUST_OS_INFO.

gcc/rust/ChangeLog:

* rust-session-manager.cc (Session::init): Call
targetrustm.rust_os_info.
* rust-target.def (rust_os_info): New hook.

10 months agorust: Reintroduce TARGET_RUST_CPU_INFO hook
Iain Buclaw [Sat, 24 Sep 2022 19:46:11 +0000 (21:46 +0200)]
rust: Reintroduce TARGET_RUST_CPU_INFO hook

gcc/ChangeLog:

* doc/tm.texi: Regenerate.
* doc/tm.texi.in: Add @node for Rust language and ABI, and document
TARGET_RUST_CPU_INFO.

gcc/rust/ChangeLog:

* rust-lang.cc (rust_add_target_info): Remove sorry.
* rust-session-manager.cc: Replace include of target.h with
include of tm.h and rust-target.h.
(Session::init): Call targetrustm.rust_cpu_info.
* rust-target.def (rust_cpu_info): New hook.
* rust-target.h (rust_add_target_info): Declare.

10 months agorust: Add skeleton support and documentation for targetrustm hooks.
Iain Buclaw [Sat, 24 Sep 2022 16:25:34 +0000 (18:25 +0200)]
rust: Add skeleton support and documentation for targetrustm hooks.

gcc/ChangeLog:

* Makefile.in (tm_rust_file_list, tm_rust_include_list, TM_RUST_H,
RUST_TARGET_DEF, RUST_TARGET_H, RUST_TARGET_OBJS): New variables.
(tm_rust.h, cs-tm_rust.h, default-rust.o,
rust/rust-target-hooks-def.h, s-rust-target-hooks-def-h): New rules.
(s-tm-texi): Also check timestamp on rust-target.def.
(generated_files): Add TM_RUST_H and rust-target-hooks-def.h.
(build/genhooks.o): Also depend on RUST_TARGET_DEF.
* config.gcc (tm_rust_file, rust_target_objs, target_has_targetrustm):
New variables.
* configure: Regenerate.
* configure.ac (tm_rust_file_list, tm_rust_include_list,
rust_target_objs): Add substitutes.
* doc/tm.texi: Regenerate.
* doc/tm.texi.in (targetrustm): Document.
(target_has_targetrustm): Document.
* genhooks.cc: Include rust/rust-target.def.
* config/default-rust.cc: New file.

gcc/rust/ChangeLog:

* rust-target-def.h: New file.
* rust-target.def: New file.
* rust-target.h: New file.

10 months agoRISC-V: Enable undefined support for RVV auto-vectorization[PR110751]
Juzhe-Zhong [Thu, 21 Sep 2023 07:19:29 +0000 (15:19 +0800)]
RISC-V: Enable undefined support for RVV auto-vectorization[PR110751]

Now GCC middle-end can support undefined value which is traslated into (scratch:mode).

This patch is to enable RISC-V backend undefine value in ELSE value of COND_LEN_xxx/COND_xxx.

Consider this following case:

  __attribute__((noipa))
  void vrem_int8_t (int8_t * __restrict dst, int8_t * __restrict a, int8_t * __restrict b, int n)
  {
    for (int i = 0; i < n; i++)
      dst[i] = a[i] % b[i];
  }

Before this patch:

vrem_int8_t:
        ble     a3,zero,.L5
        vsetvli a5,zero,e8,m1,ta,ma
        vmv.v.i v4,0                          ---> redundant.
.L3:
        vsetvli a5,a3,e8,m1,tu,ma             ---> should be TA.
        vmv1r.v v1,v4                         ---> redudant.
        vle8.v  v3,0(a1)
        vle8.v  v2,0(a2)
        sub     a3,a3,a5
        vrem.vv v1,v3,v2
        vse8.v  v1,0(a0)
        add     a1,a1,a5
        add     a2,a2,a5
        add     a0,a0,a5
        bne     a3,zero,.L3
.L5:
        ret

After this patch:

vrem_int8_t:
ble a3,zero,.L5
.L3:
vsetvli a5,a3,e8,m1,ta,ma
vle8.v v1,0(a1)
vle8.v v2,0(a2)
sub a3,a3,a5
vrem.vv v1,v1,v2
vse8.v v1,0(a0)
add a1,a1,a5
add a2,a2,a5
add a0,a0,a5
bne a3,zero,.L3
.L5:
ret

PR target/110751

gcc/ChangeLog:

* config/riscv/autovec.md: Enable scratch rtx in ELSE operand.
* config/riscv/predicates.md (autovec_else_operand): New predicate.
* config/riscv/riscv-v.cc (get_else_operand): New function.
(expand_cond_len_unop): Adapt ELSE value.
(expand_cond_len_binop): Ditto.
(expand_cond_len_ternop): Ditto.
* config/riscv/riscv.cc (riscv_preferred_else_value): New function.
(TARGET_PREFERRED_ELSE_VALUE): New targethook.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/binop/vdiv-rv32gcv-nofm.c: Adapt test.
* gcc.target/riscv/rvv/autovec/binop/vdiv-rv32gcv.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vdiv-rv64gcv-nofm.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vdiv-rv64gcv.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vrem-rv32gcv.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vrem-rv64gcv.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-10.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-11.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-12.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-6.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-7.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-8.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-9.c: Ditto.

10 months agoRISC-V: Fix SUBREG move of VLS mode[PR111486]
Juzhe-Zhong [Thu, 21 Sep 2023 06:54:33 +0000 (14:54 +0800)]
RISC-V: Fix SUBREG move of VLS mode[PR111486]

This patch fixes this bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111486

Before this patch, we can only handle (subreg:DI (reg:V8QI))

The PR ICE:

during RTL pass: reload
testcase.c: In function 'foo':
testcase.c:8:1: internal compiler error: in require, at machmode.h:313
    8 | }
      | ^
0xa40cd2 opt_mode<machine_mode>::require() const
        /repo/gcc-trunk/gcc/machmode.h:313
0xa47091 opt_mode<machine_mode>::require() const
        /repo/gcc-trunk/gcc/config/riscv/riscv.cc:2546
0xa47091 riscv_legitimize_move(machine_mode, rtx_def*, rtx_def*)
        /repo/gcc-trunk/gcc/config/riscv/riscv.cc:2543
0x1f1df10 gen_movdi(rtx_def*, rtx_def*)
        /repo/gcc-trunk/gcc/config/riscv/riscv.md:2024
0x10f1423 rtx_insn* insn_gen_fn::operator()<rtx_def*, rtx_def*>(rtx_def*, rtx_def*) const
        /repo/gcc-trunk/gcc/recog.h:411
0x10f1423 emit_move_insn_1(rtx_def*, rtx_def*)
        /repo/gcc-trunk/gcc/expr.cc:4164
0x10f183d emit_move_insn(rtx_def*, rtx_def*)
        /repo/gcc-trunk/gcc/expr.cc:4334
0x13070ec lra_emit_move(rtx_def*, rtx_def*)
        /repo/gcc-trunk/gcc/lra.cc:509
0x132295b curr_insn_transform
        /repo/gcc-trunk/gcc/lra-constraints.cc:4748
0x1324335 lra_constraints(bool)
        /repo/gcc-trunk/gcc/lra-constraints.cc:5488
0x130a3d4 lra(_IO_FILE*)
        /repo/gcc-trunk/gcc/lra.cc:2419
0x12bb629 do_reload
        /repo/gcc-trunk/gcc/ira.cc:5970
0x12bb629 execute
        /repo/gcc-trunk/gcc/ira.cc:6156

Because of (subreg:DI (reg:V2QI))

PR target/111486

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_legitimize_move): Fix bug.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr111486.c: New test.

10 months agocheck undefine_p for one more vr
Jiufu Guo [Wed, 20 Sep 2023 03:11:58 +0000 (11:11 +0800)]
check undefine_p for one more vr

The root cause of PR111355 and PR111482 is missing to check if vr0
is undefined_p before call vr0.lower_bound.

In the pattern "(X + C) / N",

    (if (INTEGRAL_TYPE_P (type)
 && get_range_query (cfun)->range_of_expr (vr0, @0))
     (if (...)
       (plus (op @0 @2) { wide_int_to_tree (type, plus_op1 (c)); })
       (if (TYPE_UNSIGNED (type) && c.sign_mask () < 0 ...
    && wi::geu_p (vr0.lower_bound (), -c))

In "(if (...)", there is code to prevent vr0's undefined_p,
But in the "else" part, vr0's undefined_p is not checked before
"wi::geu_p (vr0.lower_bound (), -c)".

PR tree-optimization/111355

gcc/ChangeLog:

* match.pd ((X + C) / N): Update pattern.

gcc/testsuite/ChangeLog:

* gcc.dg/pr111355.c: New test.

10 months agousing overflow_free_p to simplify pattern
Jiufu Guo [Fri, 15 Sep 2023 05:39:27 +0000 (13:39 +0800)]
using overflow_free_p to simplify pattern

In r14-3582, an "overflow_free_p" interface is added.
The pattern of "(t * 2) / 2" in match.pd can be simplified
by using this interface.

gcc/ChangeLog:

* match.pd ((t * 2) / 2): Update to use overflow_free_p.

10 months agoRISC-V: Optimized for strided load/store with stride == element width[PR111450]
xuli [Thu, 21 Sep 2023 03:04:56 +0000 (03:04 +0000)]
RISC-V: Optimized for strided load/store with stride == element width[PR111450]

When stride == element width, vlsse should be optimized into vle.v.
vsse should be optimized into vse.v.

PR target/111450

gcc/ChangeLog:

* config/riscv/constraints.md (c01): const_int 1.
(c02): const_int 2.
(c04): const_int 4.
(c08): const_int 8.
* config/riscv/predicates.md (vector_eew8_stride_operand): New predicate for stride operand.
(vector_eew16_stride_operand): Ditto.
(vector_eew32_stride_operand): Ditto.
(vector_eew64_stride_operand): Ditto.
* config/riscv/vector-iterators.md: New iterator for stride operand.
* config/riscv/vector.md: Add stride = element width constraint.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/pr111450.c: New test.

10 months agoRISC-V: Rename predicate vector_gs_scale_operand_16/32 to more generic names
Lehua Ding [Thu, 21 Sep 2023 03:40:07 +0000 (11:40 +0800)]
RISC-V: Rename predicate vector_gs_scale_operand_16/32 to more generic names

This little rename vector_gs_scale_operand_16/32 to more generic names
const_1_or_2/4_operand. So it's a little better understood when offered
for use elsewhere.

gcc/ChangeLog:

* config/riscv/predicates.md (const_1_or_2_operand): Rename.
(const_1_or_4_operand): Ditto.
(vector_gs_scale_operand_16): Ditto.
(vector_gs_scale_operand_32): Ditto.
* config/riscv/vector-iterators.md: Adjust.

10 months agoRISC-V: Support VLS INT <-> FP conversions
Juzhe-Zhong [Wed, 20 Sep 2023 22:22:46 +0000 (06:22 +0800)]
RISC-V: Support VLS INT <-> FP conversions

Support INT <-> FP VLS auto-vectorization patterns.

Regression passed.
Committed.

gcc/ChangeLog:

* config/riscv/autovec.md: Extend VLS modes.
* config/riscv/vector-iterators.md: Ditto.
* config/riscv/vector.md: Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/convert-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/convert-10.c: New test.
* gcc.target/riscv/rvv/autovec/vls/convert-11.c: New test.
* gcc.target/riscv/rvv/autovec/vls/convert-12.c: New test.
* gcc.target/riscv/rvv/autovec/vls/convert-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/convert-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls/convert-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls/convert-5.c: New test.
* gcc.target/riscv/rvv/autovec/vls/convert-6.c: New test.
* gcc.target/riscv/rvv/autovec/vls/convert-7.c: New test.
* gcc.target/riscv/rvv/autovec/vls/convert-8.c: New test.
* gcc.target/riscv/rvv/autovec/vls/convert-9.c: New test.

10 months agoDaily bump.
GCC Administrator [Thu, 21 Sep 2023 00:17:49 +0000 (00:17 +0000)]
Daily bump.

10 months agotestsuite: Add test for already-fixed issue with _Pragma expansion [PR90400]
Lewis Hyatt [Fri, 25 Aug 2023 19:57:19 +0000 (15:57 -0400)]
testsuite: Add test for already-fixed issue with _Pragma expansion [PR90400]

The PR was fixed by r12-5454. Since the fix was somewhat incidental,
although related, add a testcase from PR90400 too before closing it out.

gcc/testsuite/ChangeLog:

PR preprocessor/90400
* c-c++-common/cpp/pr90400.c: New test.

10 months agolibcpp: Fix ICE on #include after a line marker directive [PR61474]
Lewis Hyatt [Fri, 15 Sep 2023 17:31:51 +0000 (13:31 -0400)]
libcpp: Fix ICE on #include after a line marker directive [PR61474]

As noted in the PR, GCC will segfault if a file name is first seen in a
linemarker directive, and then later seen in a normal #include.  This is
because the fake include process adds the file to the cache with a null PATH
member. The normal #include finds this file in the cache and then attempts
to use the null PATH.  Resolve by adding the file to the cache with a unique
starting directory, so that the fake entry will only be found by a
subsequent fake include, not by a real one.

libcpp/ChangeLog:

PR preprocessor/61474
* files.cc (_cpp_find_file): Set DONT_READ to TRUE for fake
include files.
(_cpp_fake_include): Pass a unique cpp_dir* address so
the fake file will not be found when looked up for real.

gcc/testsuite/ChangeLog:

PR preprocessor/61474
* c-c++-common/cpp/pr61474-2.h: New test.
* c-c++-common/cpp/pr61474.c: New test.
* c-c++-common/cpp/pr61474.h: New test.

10 months agoTweak merge_range API.
Andrew MacLeod [Wed, 20 Sep 2023 16:53:04 +0000 (12:53 -0400)]
Tweak merge_range API.

merge_range use to return TRUE if there was already a range.  Now it
returns TRUE if a new range is added, OR updates and existing range
with a new value.  FALSE is returned when the range already matches.

* gimple-range-cache.cc (ssa_cache::merge_range): Change meaning
of the return value.
(ssa_cache::dump): Don't print GLOBAL RANGE header.
(ssa_lazy_cache::merge_range): Adjust return value meaning.
(ranger_cache::dump): Print GLOBAL RANGE header.

10 months agoaarch64: Ensure const and sign correctness
Pekka Seppänen [Wed, 20 Sep 2023 18:41:01 +0000 (19:41 +0100)]
aarch64: Ensure const and sign correctness

Be const and sign correct by using a matching CIE augmentation type.
Use a builtin instead of relying <string.h> being included.

libgcc/ChangeLog:

* config/aarch64/aarch64-unwind.h (aarch64_cie_signed_with_b_key):
Use const unsigned type and a builtin.

Signed-off-by: Pekka Seppänen <pexu@gcc.mail.kapsi.fi>
10 months agoRISC-V: Remove math.h import to resolve missing stubs failures
Patrick O'Neill [Wed, 20 Sep 2023 16:31:48 +0000 (09:31 -0700)]
RISC-V: Remove math.h import to resolve missing stubs failures

Resolves some of the missing stubs failures:
fatal error: gnu/stubs-lp64d.h: No such file or directory
compilation terminated.

2023-09-20 Juzhe Zhong <juzhe.zhong@rivai.ai>

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/def.h: Remove unneeded math.h
import.

Tested-by: Patrick O'Neill <patrick@rivosinc.com>
10 months ago[frange] Remove special casing from unordered operators.
Aldy Hernandez [Wed, 20 Sep 2023 13:46:19 +0000 (09:46 -0400)]
[frange] Remove special casing from unordered operators.

In coming up with testcases for the unordered folders, I realized that
we were already handling them correctly, even in the absence of my
work in this area lately.

All of the unordered fold_range() methods try to fold with the ordered
variants first, and if they return TRUE, we are guaranteed to be able
to fold, even in the presence of NANs.  For example:

if (x_5 >= y_8)
  if (x_5 __UNLE y_8)

On the true side of the first conditional we know that either x_5 < y_8
or that one or more operands is a NAN.  Since UNLE_EXPR returns true
for precisely this scenario, we can fold as true.

This is handled in the fold_range() methods as follows:

    if (!range_op_handler (LE_EXPR).fold_range (r, type, op1_no_nan,
op2_no_nan, trio))
      return false;
    // The result is the same as the ordered version when the
    // comparison is true or when the operands cannot be NANs.
    if (!maybe_isnan (op1, op2) || r == range_true (type))
      return true;

This code has been there since the last release, and makes the special
casing I am deleting obsolete.  I have added tests to make sure we
keep track of this behavior.

gcc/ChangeLog:

* range-op-float.cc (foperator_unordered_ge::fold_range): Remove
special casing.
(foperator_unordered_gt::fold_range): Same.
(foperator_unordered_lt::fold_range): Same.
(foperator_unordered_le::fold_range): Same.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/vrp-float-relations-5.c: New test.
* gcc.dg/tree-ssa/vrp-float-relations-6.c: New test.

10 months agoc, c++: Accept __builtin_classify_type (typename)
Jakub Jelinek [Wed, 20 Sep 2023 16:37:29 +0000 (18:37 +0200)]
c, c++: Accept __builtin_classify_type (typename)

As mentioned in my stdckdint.h mail, __builtin_classify_type has
a problem that argument promotion (the argument is passed to ...
prototyped builtin function) means that certain type classes will
simply never appear.
I think it is too late to change how it behaves, lots of code in the
wild might rely on the current behavior.

So, the following patch adds option to use a typename rather than
expression as the operand to the builtin, making it behave similarly
to sizeof, typeof or say the clang _Generic extension where the
first argument can be there not just expression, but also typename.

I think we have other prior art here, e.g. __builtin_va_arg also
expects typename.

I've added this to both C and C++, because it would be weird if it
supported it only in C and not in C++.

2023-09-20  Jakub Jelinek  <jakub@redhat.com>

gcc/
* builtins.h (type_to_class): Declare.
* builtins.cc (type_to_class): No longer static.  Return
int rather than enum.
* doc/extend.texi (__builtin_classify_type): Document.
gcc/c/
* c-parser.cc (c_parser_postfix_expression_after_primary): Parse
__builtin_classify_type call with typename as argument.
gcc/cp/
* parser.cc (cp_parser_postfix_expression): Parse
__builtin_classify_type call with typename as argument.
* pt.cc (tsubst_copy_and_build): Handle __builtin_classify_type
with dependent typename as argument.
gcc/testsuite/
* c-c++-common/builtin-classify-type-1.c: New test.
* g++.dg/ext/builtin-classify-type-1.C: New test.
* g++.dg/ext/builtin-classify-type-2.C: New test.
* gcc.dg/builtin-classify-type-1.c: New test.

10 months agointernal-fn: Support undefined rtx for uninitialized SSA_NAME[PR110751]
Juzhe-Zhong [Wed, 20 Sep 2023 14:58:49 +0000 (22:58 +0800)]
internal-fn: Support undefined rtx for uninitialized SSA_NAME[PR110751]

According to PR: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110751

As Richard and Richi suggested, we recognize uninitialized SSA_NAME and convert it
into SCRATCH rtx if the target predicate allows SCRATCH.

It can help to reduce redundant data move instructions of targets like RISC-V.

Bootstrap and Regression on x86 passed.

gcc/ChangeLog:
PR target/110751

* internal-fn.cc (expand_fn_using_insn): Support undefined rtx value.
* optabs.cc (maybe_legitimize_operand): Ditto.
(can_reuse_operands_p): Ditto.
* optabs.h (enum expand_operand_type): Ditto.
(create_undefined_input_operand): Ditto.

10 months agoc++: improve class NTTP object pretty printing [PR111471]
Patrick Palka [Wed, 20 Sep 2023 16:09:36 +0000 (12:09 -0400)]
c++: improve class NTTP object pretty printing [PR111471]

1. Move class NTTP object pretty printing to a more general spot in
   the pretty printer, so that we always print its value instead of
   its (mangled) name even when it appears outside of a template
   argument list.
2. Print the type of an class NTTP object alongside its CONSTRUCTOR
   value, like dump_expr would have done.
3. Don't print const VIEW_CONVERT_EXPR wrappers for class NTTPs.

PR c++/111471

gcc/cp/ChangeLog:

* cxx-pretty-print.cc (cxx_pretty_printer::expression)
<case VAR_DECL>: Handle class NTTP objects by printing
their type and value.
<case VIEW_CONVERT_EXPR>: Strip const VIEW_CONVERT_EXPR
wrappers for class NTTPs.
(pp_cxx_template_argument_list): Don't handle class NTTP
objects here.

gcc/testsuite/ChangeLog:

* g++.dg/concepts/diagnostic19.C: New test.

10 months agoc++: further optimize tsubst_template_decl
Patrick Palka [Wed, 20 Sep 2023 16:07:15 +0000 (12:07 -0400)]
c++: further optimize tsubst_template_decl

This patch makes tsubst_template_decl use use_spec_table=false also in
the non-class non-function template case, to avoid computing 'argvec' and
doing a hash table lookup from tsubst_decl (when partially instantiating
a member variable/alias template).

This change reveals that for function templates, tsubst_template_decl
registers the partially instantiated TEMPLATE_DECL, whereas for other
non-class templates it registers the corresponding DECL_TEMPLATE_RESULT
which is an interesting inconsistency that I decided to preserve for now.
Trying to consistently register the TEMPLATE_DECL (or DECL_TEMPLATE_RESULT)
causes modules ICEs which I didn't look into.

In passing, in tsubst_function_decl I noticed 'argvec' is unused
when 'lambda_fntype' is set (since lambdas aren't recorded in the
specializations table), so we can avoid computing it in that case.

gcc/cp/ChangeLog:

* pt.cc (tsubst_function_decl): Don't bother computing 'argvec'
when 'lambda_fntype' is set.
(tsubst_template_decl): Make sure we return a TEMPLATE_DECL
during specialization lookup.  In the non-class non-function
template case, use tsubst_decl directly with use_spec_table=false,
update DECL_TI_ARGS and call register_specialization like
tsubst_decl would have done if use_spec_table=true.

10 months agoOpenMP: Add ME support for 'omp allocate' stack variables
Tobias Burnus [Wed, 20 Sep 2023 14:03:19 +0000 (16:03 +0200)]
OpenMP: Add ME support for 'omp allocate' stack variables

Call GOMP_alloc/free for 'omp allocate' allocated variables. This is
for C only as C++ and Fortran show a sorry already in the FE. Note that
this only applies to stack variables as the C FE shows a sorry for
static variables.

gcc/ChangeLog:

* gimplify.cc (gimplify_bind_expr): Call GOMP_alloc/free for
'omp allocate' variables; move stack cleanup after other
cleanup.
(omp_notice_variable): Process original decl when decl
of the value-expression for a 'omp allocate' variable is passed.
* omp-low.cc (scan_omp_1_op): Handle 'omp allocate' variables

libgomp/ChangeLog:

* libgomp.texi (OpenMP 5.1 Impl.): Mark 'omp allocate' as
implemented for C only.
* testsuite/libgomp.c/allocate-4.c: New test.
* testsuite/libgomp.c/allocate-5.c: New test.
* testsuite/libgomp.c/allocate-6.c: New test.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/allocate-11.c: Remove C-only dg-message
for 'sorry, unimplemented'.
* c-c++-common/gomp/allocate-12.c: Likewise.
* c-c++-common/gomp/allocate-15.c: Likewise.
* c-c++-common/gomp/allocate-9.c: Likewise.
* c-c++-common/gomp/allocate-10.c: New test.
* c-c++-common/gomp/allocate-17.c: New test.

10 months agoRISC-V: Support simplifying x/(-1) to neg for vector.
Yanzhang Wang [Wed, 20 Sep 2023 03:36:20 +0000 (11:36 +0800)]
RISC-V: Support simplifying x/(-1) to neg for vector.

gcc/ChangeLog:

* simplify-rtx.cc (simplify_context::simplify_binary_operation_1):
support simplifying vector int not only scalar int.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/simplify-vdiv.c: New test.

Signed-off-by: Yanzhang Wang <yanzhang.wang@intel.com>
10 months agoRISC-V: Support VLS floating-point extend/truncate
Juzhe-Zhong [Wed, 20 Sep 2023 11:51:19 +0000 (19:51 +0800)]
RISC-V: Support VLS floating-point extend/truncate

Regression passed.

Committed.

gcc/ChangeLog:

* config/riscv/vector-iterators.md: Extend VLS floating-point.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/widen/widen-10.c: Adapt test.
* gcc.target/riscv/rvv/autovec/widen/widen-11.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-12.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-complicate-7.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-complicate-8.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-complicate-9.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/ext-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls/ext-5.c: New test.
* gcc.target/riscv/rvv/autovec/vls/trunc-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls/trunc-5.c: New test.

10 months agoRISC-V: Fix Demand comparison bug[VSETVL PASS]
Juzhe-Zhong [Wed, 20 Sep 2023 08:07:49 +0000 (16:07 +0800)]
RISC-V: Fix Demand comparison bug[VSETVL PASS]

This bug is exposed when we support VLS integer conversion patterns.

FAIL: c-c++-common/torture/pr53505.c execution.

This is because incorrect vsetvl elimination by Phase 4:

   10318:       0d207057                vsetvli zero,zero,e32,m4,ta,ma
   1031c:       5e003e57                vmv.v.i v28,0
   .....:       ........                missed e8,m1 vsetvl
   10320:       7b07b057                vmsgtu.vi       v0,v16,15
   10324:       03083157                vadd.vi v2,v16,-16

Regression on release version GCC no surprise difference.

Committed.

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc (vector_insn_info::operator==): Fix bug.

10 months agoDarwin: Move checking of the 'shared' driver spec.
Iain Sandoe [Sun, 9 Jul 2023 08:02:39 +0000 (09:02 +0100)]
Darwin: Move checking of the 'shared' driver spec.

This avoids a bunch of irrelevant diagnostics if the user passes '-shared' to
gnatmake.  Currently, we push '-dynamiclib' back onto the command line (since
that is the Darwin spelling of 'shared') but this is not handled by gnat1,
leading to a diagnostic for every character after the '-d'.

'-shared' has no effect on gnatmake (it needs to be passed to gnatbind).

This moves the handling of '-shared' to leaf specs so that we do not need to
push 'dynamiclib' onto the command line.

gcc/ChangeLog:

* config/darwin.h:
(SUBTARGET_DRIVER_SELF_SPECS): Move handling of 'shared' into the same
specs as 'dynamiclib'. (STARTFILE_SPEC): Handle 'shared'.

10 months agotree-optimization/111489 - raise --param uninit-max-chain-len to 8
Richard Biener [Wed, 20 Sep 2023 06:44:43 +0000 (08:44 +0200)]
tree-optimization/111489 - raise --param uninit-max-chain-len to 8

This raises --param uninit-max-chain-len to avoid a bogus diagnostic
for the large testcase in PR111489.

PR tree-optimization/111489
* params.opt (-param uninit-max-chain-len=): Raise default to 8.

* gcc.dg/uninit-pr111489.c: New testcase.

10 months agotree-optimization/111489 - turn uninit limits to params
Richard Biener [Wed, 20 Sep 2023 06:40:34 +0000 (08:40 +0200)]
tree-optimization/111489 - turn uninit limits to params

The following turns MAX_NUM_CHAINS and MAX_CHAIN_LEN to params which
allows to experiment with raising them.  For the testcase in PR111489
raising MAX_CHAIN_LEN from 5 to 8 avoids the bogus diagnostics
at -O2, at -O3 we need a MAX_CHAIN_LEN of 6.

PR tree-optimization/111489
* doc/invoke.texi (--param uninit-max-chain-len): Document.
(--param uninit-max-num-chains): Likewise.
* params.opt (-param=uninit-max-chain-len=): New.
(-param=uninit-max-num-chains=): Likewise.
* gimple-predicate-analysis.cc (MAX_NUM_CHAINS): Define to
param_uninit_max_num_chains.
(MAX_CHAIN_LEN): Define to param_uninit_max_chain_len.
(uninit_analysis::init_use_preds): Avoid VLA.
(uninit_analysis::init_from_phi_def): Likewise.
(compute_control_dep_chain): Avoid using MAX_CHAIN_LEN in
template parameter.

10 months agomiddle-end: use MAX_FIXED_MODE_SIZE instead of precidion of TImode/DImode
Jakub Jelinek [Wed, 20 Sep 2023 07:45:42 +0000 (09:45 +0200)]
middle-end: use MAX_FIXED_MODE_SIZE instead of precidion of TImode/DImode

On Tue, Sep 19, 2023 at 05:50:59PM +0100, Richard Sandiford wrote:
> How about using MAX_FIXED_MODE_SIZE for things like this?

Seems like a good idea.

The following patch does that.

2023-09-20  Jakub Jelinek  <jakub@redhat.com>

* match.pd ((x << c) >> c): Use MAX_FIXED_MODE_SIZE instead of
GET_MODE_PRECISION of TImode or DImode depending on whether
TImode is supported scalar mode.
* gimple-lower-bitint.cc (bitint_precision_kind): Likewise.
* expr.cc (expand_expr_real_1): Likewise.
* tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_stmt): Likewise.
* ubsan.cc (ubsan_encode_value, ubsan_type_descriptor): Likewise.

10 months agoRISC-V: Reorganize and rename combine patterns in autovec-opt.md
Lehua Ding [Wed, 20 Sep 2023 06:48:23 +0000 (14:48 +0800)]
RISC-V: Reorganize and rename combine patterns in autovec-opt.md

This patch reorganize and rename the combine patterns in autovec-opt.md
by category. There shouldn't be any functional changes.
The current classification includes the following categories:

- Combine op + vmerge to cond_op
- Combine binop + trunc to narrow_binop
- Combine extend + binop to widen_binop
- Combine extend + ternop to widen_ternop
- Misc combine patterns

gcc/ChangeLog:

* config/riscv/autovec-opt.md (*<optab>not<mode>): Move and rename.
(*n<optab><mode>): Ditto.
(*v<any_shiftrt:optab><any_extend:optab>trunc<mode>): Ditto.
(*<any_shiftrt:optab>trunc<mode>): Ditto.
(*narrow_<any_shiftrt:optab><any_extend:optab><mode>): Ditto.
(*narrow_<any_shiftrt:optab><mode>_scalar): Ditto.
(*single_widen_mult<any_extend:su><mode>): Ditto.
(*single_widen_mul<any_extend:su><mode>): Ditto.
(*single_widen_mult<mode>): Ditto.
(*single_widen_mul<mode>): Ditto.
(*dual_widen_fma<mode>): Ditto.
(*dual_widen_fma<su><mode>): Ditto.
(*single_widen_fma<mode>): Ditto.
(*single_widen_fma<su><mode>): Ditto.
(*dual_fma<mode>): Ditto.
(*single_fma<mode>): Ditto.
(*dual_fnma<mode>): Ditto.
(*dual_widen_fnma<mode>): Ditto.
(*single_fnma<mode>): Ditto.
(*single_widen_fnma<mode>): Ditto.
(*dual_fms<mode>): Ditto.
(*dual_widen_fms<mode>): Ditto.
(*single_fms<mode>): Ditto.
(*single_widen_fms<mode>): Ditto.
(*dual_fnms<mode>): Ditto.
(*dual_widen_fnms<mode>): Ditto.
(*single_fnms<mode>): Ditto.
(*single_widen_fnms<mode>): Ditto.

10 months agoopenmp: Add omp::decl attribute support [PR111392]
Jakub Jelinek [Wed, 20 Sep 2023 06:43:02 +0000 (08:43 +0200)]
openmp: Add omp::decl attribute support [PR111392]

This patch adds support for (so far C++) omp::decl attribute.  For
declare simd and declare variant directives it is essentially another
spelling of omp::decl, except per discussions it is not allowed inside
of omp::sequence attribute.  For threadprivate, declare target, allocate
and later groupprivate directives it should appertain to variable (or for
declare target also function definitions and) declarations and where in
normal syntax one specifies a list of variables (or variables and functions),
either as argument of the directive or clause argument, such argument is
not specified and implied to be the variable it applies to.

2023-09-20  Jakub Jelinek  <jakub@redhat.com>

PR c++/111392
gcc/
* attribs.cc (decl_attributes): Don't warn on omp::directive attribute
on vars or function decls if -fopenmp or -fopenmp-simd.
gcc/c-family/
* c-omp.cc (c_omp_directives): Add commented out groupprivate
directive entry.
gcc/cp/
* parser.h (struct cp_lexer): Add in_omp_decl_attribute member.
* cp-tree.h (cp_maybe_parse_omp_decl): Declare.
* parser.cc (cp_parser_handle_statement_omp_attributes): Diagnose
omp::decl attribute on statements.  Adjust diagnostic wording for
omp::decl.
(cp_parser_omp_directive_args): Add DECL_P argument, set TREE_PUBLIC
to it on the DEFERRED_PARSE tree.
(cp_parser_omp_sequence_args): Adjust caller.
(cp_parser_std_attribute): Handle omp::decl attribute.
(cp_parser_omp_var_list): If parser->lexer->in_omp_decl_attribute
don't expect any arguments, instead create clause or TREE_LIST for
that decl.
(cp_parser_late_parsing_omp_declare_simd): Adjust diagnostic wording
for omp::decl.
(cp_maybe_parse_omp_decl): New function.
(cp_parser_omp_declare_target): If
parser->lexer->in_omp_decl_attribute and first token isn't name or
comma invoke cp_parser_omp_var_list.
* decl2.cc (cplus_decl_attributes): Adjust diagnostic wording for
omp::decl.  Handle omp::decl on declarations.
* name-lookup.cc (finish_using_directive): Adjust diagnostic wording
for omp::decl.
gcc/testsuite/
* g++.dg/gomp/attrs-19.C: New test.
* g++.dg/gomp/attrs-20.C: New test.
* g++.dg/gomp/attrs-21.C: New test.
libgomp/
* libgomp.texi: Mark decl attribute was added to the C++ attribute
syntax as implemented.

10 months agoRISC-V: Fixed ICE caused by missing operand
Lehua Ding [Wed, 20 Sep 2023 05:35:16 +0000 (13:35 +0800)]
RISC-V: Fixed ICE caused by missing operand

This ICE appears in GCC compiled with -O2 flags.

PR target/111488

gcc/ChangeLog:

* config/riscv/autovec-opt.md: Add missed operand.

10 months agodebug/111409 - don't generate COMDAT macro sections for split DWARF
Omar Sandoval [Thu, 14 Sep 2023 06:41:22 +0000 (23:41 -0700)]
debug/111409 - don't generate COMDAT macro sections for split DWARF

Split DWARF files aren't processed by the linker, so DW_MACRO_import
offsets aren't relocated and the .debug_macro.dwo sections aren't
deduplicated and merged.  There's no clear way for this to work for
split DWARF, so disable it.

gcc/ChangeLog:

PR debug/111409
* dwarf2out.cc (output_macinfo): Don't call optimize_macinfo_range if
dwarf_split_debug_info.

gcc/testsuite/ChangeLog:

PR debug/111409
* gcc.dg/pr111409.c: New test.

10 months agotestcase: rename pr111303.c to pr111324.c
Jiufu Guo [Mon, 18 Sep 2023 06:18:56 +0000 (14:18 +0800)]
testcase: rename pr111303.c to pr111324.c

When commit the fix for pr111324, the test cases was named as pr111303.c
by mistake.  Here, rename it to pr111324.c

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr111303.c: Rename to ...
* gcc.dg/tree-ssa/pr111324.c: ... this.

10 months agoRISC-V: Extend VLS modes in 'VWEXTI' iterator
Juzhe-Zhong [Tue, 19 Sep 2023 22:49:56 +0000 (06:49 +0800)]
RISC-V: Extend VLS modes in 'VWEXTI' iterator

This patch extends 'VWEXT' iterator so that we will support
integer extension/integer truncate/integer average VLS patterns.

This patch reduce these following FAILs:

FAIL: gcc.dg/pr92301.c execution test
XPASS: gcc.dg/vect/bb-slp-subgroups-3.c -flto -ffat-lto-objects  scan-tree-dump-times slp2 "optimized: basic block" 2
XPASS: gcc.dg/vect/bb-slp-subgroups-3.c scan-tree-dump-times slp2 "optimized: basic block" 2

The pr92301.c is the latent bug in middle-end GIMPLE FOLD.
We are just lucky that this test passes with this patch which makes us not trigger the GIMPLE FOLD bug again.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (can_find_related_mode_p): New function.
(vectorize_related_mode): Add VLS related modes.
* config/riscv/vector-iterators.md: Extend VLS modes.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/binop/narrow-1.c: Adapt testcase.
* gcc.target/riscv/rvv/autovec/binop/narrow-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/narrow-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/cmp/vcond-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/cmp/vcond-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/cmp/vcond-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/cmp/vcond-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/partial/slp-18.c: Ditto.
* gcc.target/riscv/rvv/autovec/partial/slp-19.c: Ditto.
* gcc.target/riscv/rvv/autovec/pr110950.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop-10.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop-11.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop-12.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop-6.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop-7.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop-8.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop-9.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-10.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-11.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-12.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-6.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-7.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-8.c: Ditto.
* gcc.target/riscv/rvv/autovec/ternop/ternop_nofm-9.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/def.h: Ditto.
* gcc.target/riscv/rvv/autovec/vls/div-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/shift-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-6.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-7.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-8.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-9.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-complicate-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-complicate-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-complicate-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-complicate-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-complicate-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/widen/widen-complicate-6.c: Ditto.
* gcc.target/riscv/rvv/autovec/zve32f-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/vls/avg-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/avg-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/avg-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls/avg-4.c: New test.
* gcc.target/riscv/rvv/autovec/vls/avg-5.c: New test.
* gcc.target/riscv/rvv/autovec/vls/avg-6.c: New test.
* gcc.target/riscv/rvv/autovec/vls/ext-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/ext-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/ext-3.c: New test.
* gcc.target/riscv/rvv/autovec/vls/trunc-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/trunc-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/trunc-3.c: New test.

10 months agoira: Consider save/restore costs of callee-save registers [PR110071]
Surya Kumari Jangala [Thu, 14 Sep 2023 07:12:50 +0000 (02:12 -0500)]
ira: Consider save/restore costs of callee-save registers [PR110071]

In improve_allocation() routine, IRA checks for each allocno if spilling
any conflicting allocnos can improve the allocation of this allocno.
This routine computes the cost improvement for usage of each profitable
hard register for a given allocno. The existing code in
improve_allocation() does not consider the save/restore costs of callee
save registers while computing the cost improvement.

This can result in a callee save register being assigned to a pseudo
that is live in the entire function and across a call, overriding a
non-callee save register assigned to the pseudo by graph coloring. So
the entry basic block requires a prolog, thereby causing shrink wrap to
fail.

2023-09-14  Surya Kumari Jangala  <jskumari@linux.ibm.com>

gcc/
PR rtl-optimization/110071
* ira-color.cc (improve_allocation): Consider cost of callee
save registers.

gcc/testsuite/
PR rtl-optimization/110071
* gcc.target/powerpc/pr110071.c: New test.

10 months agoModify gas uleb128 support test
mengqinggang [Fri, 15 Sep 2023 04:04:04 +0000 (12:04 +0800)]
Modify gas uleb128 support test

Some assemblers (GNU as for LoongArch) generates relocations for leb128
symbol arithmetic for relaxation, we need to disable relaxation probing
leb128 support then.

gcc/ChangeLog:

* configure: Regenerate.
* configure.ac: Checking assembler for -mno-relax support.
Disable relaxation when probing leb128 support.

co-authored-by: Xi Ruoyao <xry111@xry111.site>

10 months agoLoongArch: Check whether binutils supports the relax function. If supported, explicit...
Lulu Cheng [Fri, 15 Sep 2023 02:22:49 +0000 (10:22 +0800)]
LoongArch: Check whether binutils supports the relax function. If supported, explicit relocs are turned off by default.

gcc/ChangeLog:

* config.in: Regenerate.
* config/loongarch/genopts/loongarch.opt.in: Add compilation option
mrelax. And set the initial value of explicit-relocs according to the
detection status.
* config/loongarch/gnu-user.h: When compiling with -mno-relax, pass the
--no-relax option to the linker.
* config/loongarch/loongarch-driver.h (ASM_SPEC): When compiling with
-mno-relax, pass the -mno-relax option to the assembler.
* config/loongarch/loongarch-opts.h (HAVE_AS_MRELAX_OPTION): Define macro.
* config/loongarch/loongarch.opt: Regenerate.
* configure: Regenerate.
* configure.ac: Add detection of support for binutils relax function.

10 months agoDaily bump.
GCC Administrator [Wed, 20 Sep 2023 00:17:55 +0000 (00:17 +0000)]
Daily bump.

10 months agoc++modules: report module mapper files as a dependency
Ben Boeckel [Fri, 1 Sep 2023 13:04:04 +0000 (09:04 -0400)]
c++modules: report module mapper files as a dependency

It affects the build, and if used as a static file, can reliably be
tracked using the `-MF` mechanism.

gcc/cp/:

* mapper-client.cc, mapper-client.h (open_module_client): Accept
dependency tracking and track module mapper files as
dependencies.
* module.cc (make_mapper, get_mapper): Pass the dependency
tracking class down.

gcc/testsuite/:

* g++.dg/modules/depreport-2.modmap: New test.
* g++.dg/modules/depreport-2_a.C: New test.
* g++.dg/modules/depreport-2_b.C: New test.
* g++.dg/modules/test-depfile.py: Support `:|` syntax output
when generating modules.

Signed-off-by: Ben Boeckel <ben.boeckel@kitware.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
10 months agoc++modules: report imported CMI files as dependencies
Ben Boeckel [Fri, 1 Sep 2023 13:04:03 +0000 (09:04 -0400)]
c++modules: report imported CMI files as dependencies

They affect the build, so report them via `-MF` mechanisms.

gcc/cp/

* module.cc (do_import): Report imported CMI files as
dependencies.

gcc/testsuite/

* g++.dg/modules/depreport-1_a.C: New test.
* g++.dg/modules/depreport-1_b.C: New test.
* g++.dg/modules/test-depfile.py: New tool for validating depfile
information.
* lib/modules.exp: Support for validating depfile contents.

Signed-off-by: Ben Boeckel <ben.boeckel@kitware.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
10 months agop1689r5: initial support
Ben Boeckel [Fri, 1 Sep 2023 13:04:02 +0000 (09:04 -0400)]
p1689r5: initial support

This patch implements support for [P1689R5][] to communicate to a build
system the C++20 module dependencies to build systems so that they may
build `.gcm` files in the proper order.

Support is communicated through the following three new flags:

- `-fdeps-format=` specifies the format for the output. Currently named
  `p1689r5`.

- `-fdeps-file=` specifies the path to the file to write the format to.

- `-fdeps-target=` specifies the `.o` that will be written for the TU
  that is scanned. This is required so that the build system can
  correlate the dependency output with the actual compilation that will
  occur.

CMake supports this format as of 17 Jun 2022 (to be part of 3.25.0)
using an experimental feature selection (to allow for future usage
evolution without committing to how it works today). While it remains
experimental, docs may be found in CMake's documentation for
experimental features.

Future work may include using this format for Fortran module
dependencies as well, however this is still pending work.

[P1689R5]: https://isocpp.org/files/papers/P1689R5.html
[cmake-experimental]: https://gitlab.kitware.com/cmake/cmake/-/blob/master/Help/dev/experimental.rst

TODO:

- header-unit information fields

Header units (including the standard library headers) are 100%
unsupported right now because the `-E` mechanism wants to import their
BMIs. A new mode (i.e., something more workable than existing `-E`
behavior) that mocks up header units as if they were imported purely
from their path and content would be required.

- non-utf8 paths

The current standard says that paths that are not unambiguously
represented using UTF-8 are not supported (because these cases are rare
and the extra complication is not worth it at this time). Future
versions of the format might have ways of encoding non-UTF-8 paths. For
now, this patch just doesn't support non-UTF-8 paths (ignoring the
"unambiguously representable in UTF-8" case).

- figure out why junk gets placed at the end of the file

Sometimes it seems like the file gets a lot of `NUL` bytes appended to
it. It happens rarely and seems to be the result of some
`ftruncate`-style call which results in extra padding in the contents.
Noting it here as an observation at least.

libcpp/

* include/cpplib.h: Add cpp_fdeps_format enum.
(cpp_options): Add fdeps_format field
(cpp_finish): Add structured dependency fdeps_stream parameter.
* include/mkdeps.h (deps_add_module_target): Add flag for
whether a module is exported or not.
(fdeps_add_target): Add function.
(deps_write_p1689r5): Add function.
* init.cc (cpp_finish): Add new preprocessor parameter used for C++
module tracking.
* mkdeps.cc (mkdeps): Implement P1689R5 output.

gcc/

* doc/invoke.texi: Document -fdeps-format=, -fdeps-file=, and
-fdeps-target= flags.
* gcc.cc: add defaults for -fdeps-target= and -fdeps-file= when
only -fdeps-format= is specified.
* json.h: Add a TODO item to refactor out to share with
`libcpp/mkdeps.cc`.

gcc/c-family/

* c-opts.cc (c_common_handle_option): Add fdeps_file variable and
-fdeps-format=, -fdeps-file=, and -fdeps-target= parsing.
* c.opt: Add -fdeps-format=, -fdeps-file=, and -fdeps-target=
flags.

gcc/cp/

* module.cc (preprocessed_module): Pass whether the module is
exported to dependency tracking.

gcc/testsuite/

* g++.dg/modules/depflags-f-MD.C: New test.
* g++.dg/modules/depflags-f.C: New test.
* g++.dg/modules/depflags-fi.C: New test.
* g++.dg/modules/depflags-fj-MD.C: New test.
* g++.dg/modules/depflags-fj.C: New test.
* g++.dg/modules/depflags-fjo-MD.C: New test.
* g++.dg/modules/depflags-fjo.C: New test.
* g++.dg/modules/depflags-fo-MD.C: New test.
* g++.dg/modules/depflags-fo.C: New test.
* g++.dg/modules/depflags-j-MD.C: New test.
* g++.dg/modules/depflags-j.C: New test.
* g++.dg/modules/depflags-jo-MD.C: New test.
* g++.dg/modules/depflags-jo.C: New test.
* g++.dg/modules/depflags-o-MD.C: New test.
* g++.dg/modules/depflags-o.C: New test.
* g++.dg/modules/p1689-1.C: New test.
* g++.dg/modules/p1689-1.exp.ddi: New test expectation.
* g++.dg/modules/p1689-2.C: New test.
* g++.dg/modules/p1689-2.exp.ddi: New test expectation.
* g++.dg/modules/p1689-3.C: New test.
* g++.dg/modules/p1689-3.exp.ddi: New test expectation.
* g++.dg/modules/p1689-4.C: New test.
* g++.dg/modules/p1689-4.exp.ddi: New test expectation.
* g++.dg/modules/p1689-5.C: New test.
* g++.dg/modules/p1689-5.exp.ddi: New test expectation.
* g++.dg/modules/modules.exp: Load new P1689 library routines.
* g++.dg/modules/test-p1689.py: New tool for validating P1689 output.
* lib/modules.exp: Support for validating P1689 outputs.

Signed-off-by: Ben Boeckel <ben.boeckel@kitware.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
10 months agospec: add a spec function to join arguments
Ben Boeckel [Fri, 1 Sep 2023 13:04:01 +0000 (09:04 -0400)]
spec: add a spec function to join arguments

When passing `-o` flags to other options, the typical `-o foo` spelling
leaves a leading whitespace when replacing elsewhere. This ends up
creating flags spelled as `-some-option-with-arg= foo.ext` which doesn't
parse properly. When attempting to make a spec function to just remove
the leading whitespace, the argument splitting ends up masking the
whitespace. However, the intended extension *also* ends up being its own
argument. To perform the desired behavior, the arguments need to be
concatenated together.

gcc/:

* gcc.cc (join_spec_func): Add a spec function to join all
arguments.

Signed-off-by: Ben Boeckel <ben.boeckel@kitware.com>
Co-authored-by: Jason Merrill <jason@redhat.com>
10 months agoRISC-V: Fix --enable-checking=rtl ICE on rv32gc bootstrap
Patrick O'Neill [Tue, 19 Sep 2023 17:03:35 +0000 (10:03 -0700)]
RISC-V: Fix --enable-checking=rtl ICE on rv32gc bootstrap

Resolves PR 111461.

during RTL pass: expand
offtime.c: In function '__offtime':
offtime.c:79:6: internal compiler error: RTL check: expected elt 0 type 'e' or 'u', have 'w' (rtx const_int) in riscv_legitimize_const_move, at config/riscv/riscv.cc:2176
   79 |   ip = __mon_yday[__isleap(y)];

Tested on rv32gc glibc with --enable-checking=rtl.

2023-09-19 Juzhe Zhong <juzhe.zhong@rivai.ai>

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_legitimize_const_move): Eliminate
src_op_0 var to avoid rtl check error.

Tested-by: Patrick O'Neill <patrick@rivosinc.com>
10 months ago[frange] Clean up floating point relational folding.
Aldy Hernandez [Tue, 19 Sep 2023 01:41:08 +0000 (21:41 -0400)]
[frange] Clean up floating point relational folding.

The following patch removes all the special casing from the floating
point relational folding code.  Now all the code relating to folding
of relationals is in frelop_early_resolve() and in
operator_not_equal::fold_range() which requires a small tweak.

I have written new relational tests, and moved them to
gcc.dg/tree-ssa/vrp-float-relations-* for easy reference.  In the
tests it's easy to see the type of things we need to handle:

(a)
if (x != y)
  if (x == y)
    link_error ();

(b)
if (a != b)
  if (a != b) // Foldable as true.

(c)
/* We can thread BB2->BB4->BB5 even though we have no knowledge
   of the NANness of either x_1 or a_5.  */
__BB(4):
  x_1 = __PHI (__BB2: a_5(D), __BB3: b_4(D));
  if (x_1 __UNEQ a_5(D))

(d)
/* Even though x_1 and a_4 are equivalent on the BB2->BB4 path,
   we cannot fold the conditional because of possible NANs:  */
__BB(4):
  # x_1 = __PHI (__BB2: a_4(D), __BB3: 8.0e+0(3));
  if (x_1 == a_4(D))

(e)
if (cond)
  x = a;
else
  x = 8.0;

/* We can fold this as false on the path coming out of cond==1,
   regardless of NANs on either "x" or "a".  */
if (x < a)
  stuff ();

[etc, etc]

We can implement everything without either special casing,
get_identity_relation(), or adding new unordered relationals.

The basic idea is that if we accurately reflect NANs in op[12]_range,
this information gets propagated to the relevant edges, and there's no
need for unordered relations (VREL_UN*), because the information is in
the range itself.  This information is then used in
frelop_early_resolve() to fold certain combinations.

I don't mean this patch as a hard-no against implementing the
unordered relations Jakub preferred, but seeing that it's looking
cleaner and trivially simple without the added burden of more enums,
I'd like to flesh it out completely and then discuss if we still think
new codes are needed.

More testcases or corner cases are highly welcome.

In follow-up patches I will finish up unordered relation folding, and
come up with suitable tests.

gcc/ChangeLog:

* range-op-float.cc (frelop_early_resolve): Clean-up and remove
special casing.
(operator_not_equal::fold_range): Handle VREL_EQ.
(operator_lt::fold_range): Remove special casing for VREL_EQ.
(operator_gt::fold_range): Same.
(foperator_unordered_equal::fold_range): Same.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/vrp-float-12.c: Moved to...
* gcc.dg/tree-ssa/vrp-float-relations-1.c: ...here.
* gcc.dg/tree-ssa/vrp-float-relations-2.c: New test.
* gcc.dg/tree-ssa/vrp-float-relations-3.c: New test.
* gcc.dg/tree-ssa/vrp-float-relations-4.c: New test.

10 months agoc++: extend cold, hot attributes to classes
Javier Martinez [Wed, 23 Aug 2023 13:02:40 +0000 (15:02 +0200)]
c++: extend cold, hot attributes to classes

Most code is cold. This patch extends support for attribute ((cold)) to C++
Classes, Unions, and Structs (RECORD_TYPES and UNION_TYPES) to benefit from
encapsulation - reducing the verbosity of using the attribute where
deserved. The ((hot)) attribute is also extended for its semantic relation.

gcc/c-family/ChangeLog:

* c-attribs.cc (handle_hot_attribute): remove warning on
RECORD_TYPE and UNION_TYPE when in c_dialect_xx.
(handle_cold_attribute): Likewise.

gcc/cp/ChangeLog:

* class.cc (propagate_class_warmth_attribute): New function.
(check_bases_and_members): propagate hot and cold attributes
to all FUNCTION_DECL when the record is marked hot or cold.
* cp-tree.h (maybe_propagate_warmth_attributes): New function.
* decl2.cc (maybe_propagate_warmth_attributes): New function.
* method.cc (lazily_declare_fn): propagate hot and cold
attributes to lazily declared functions when the record is
marked hot or cold.

gcc/ChangeLog:

* doc/extend.texi: Document attributes hot, cold on C++ types.

gcc/testsuite/ChangeLog:

* g++.dg/ext/attr-hotness.C: New test.

Signed-off-by: Javier Martinez <javier.martinez.bugzilla@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
10 months agoc++: fix cxx_print_type's template-info dumping
Patrick Palka [Tue, 19 Sep 2023 18:38:10 +0000 (14:38 -0400)]
c++: fix cxx_print_type's template-info dumping

Unlike DECL_TEMPLATE_INFO which is stored in DECL_LANG_SPECIFIC,
TYPE_TEMPLATE_INFO isn't stored in TYPE_LANG_SPECIFIC, so we don't
need to check for both in cxx_print_type.  This fixes dumping the
template-info of ENUMERAL_TYPE and BOUND_TEMPLATE_TEMPLATE_PARM,
which seem to never have TYPE_LANG_SPECIFIC.

gcc/cp/ChangeLog:

* ptree.cc (cxx_print_type): Remove TYPE_LANG_SPECIFIC
test guarding TYPE_TEMPLATE_INFO.

10 months agoDisable generation of scalar modulo instructions.
Pat Haugen [Tue, 19 Sep 2023 18:19:59 +0000 (13:19 -0500)]
Disable generation of scalar modulo instructions.

It was recently discovered that the scalar modulo instructions can suffer
noticeable performance issues for certain input values. This patch disables
their generation since the equivalent div/mul/sub sequence does not suffer
the same problem.

gcc/
* config/rs6000/rs6000.cc (rs6000_rtx_costs): Check whether the
modulo instruction is disabled.
* config/rs6000/rs6000.h (RS6000_DISABLE_SCALAR_MODULO): New.
* config/rs6000/rs6000.md (mod<mode>3, *mod<mode>3): Check it.
(define_expand umod<mode>3): New.
(define_insn umod<mode>3): Rename to *umod<mode>3 and check if the modulo
instruction is disabled.
(umodti3, modti3): Check if the modulo instruction is disabled.

gcc/testsuite/
* gcc.target/powerpc/clone1.c: Add xfails.
* gcc.target/powerpc/clone3.c: Likewise.
* gcc.target/powerpc/mod-1.c: Update scan strings and add xfails.
* gcc.target/powerpc/mod-2.c: Likewise.
* gcc.target/powerpc/p10-vdivq-vmodq.c: Add xfails.

10 months agoPR 108143/modula2 LONGREAL and powerpc64le-linux
Gaius Mulley [Tue, 19 Sep 2023 18:23:03 +0000 (19:23 +0100)]
PR 108143/modula2 LONGREAL and powerpc64le-linux

This patch introduces a configure for LONGREAL as float128 when
targetting or hosting cc1gm2 on ppc64le.  It fixes calls to builtins
and fixes the -fdebug-builtins option.

gcc/ChangeLog:

* doc/gm2.texi (fdebug-builtins): Correct description.

gcc/m2/ChangeLog:

* Make-lang.in (host_mc_longreal): Detect hosting on powerpc64le
and if so use __float128 for longreal in mc.
(MC_ARGS): Append host_mc_longreal.
* config-make.in (TEST_TARGET_CPU_DEFAULT): New variable.
(TEST_HOST_CPU_DEFAULT): New variable.
* configure: Regenerate.
* configure.ac (M2C_LONGREAL_FLOAT128): New define set if target
is powerpc64le.
(M2C_LONGREAL_PPC64LE): New define set if target is powerpc64le.
* gm2-compiler/M2GCCDeclare.mod: Correct comment case.
* gm2-compiler/M2GenGCC.mod (MaybeDebugBuiltinAlloca): Call
SetLastFunction for the builtin function call.
(MaybeDebugBuiltinMemcpy): Call SetLastFunction for the builtin
function call.
(MaybeDebugBuiltinMemset): New procedure function.
(MakeCopyUse): Use GNU formatting.
(UseBuiltin): Rewrite to check BuiltinExists.
(CodeDirectCall): Rewrite to check BuiltinExists and call
SetLastFunction.
(CodeMakeAdr): Re-format.
* gm2-compiler/M2Options.def (SetDebugBuiltins): New procedure.
* gm2-compiler/M2Options.mod (SetUninitVariableChecking): Allow
"cond" to switch UninitVariableConditionalChecking separately.
(SetDebugBuiltins): New procedure.
* gm2-compiler/M2Quads.def (BuildFunctionCall): Add parameter
ConstExpr.
* gm2-compiler/M2Quads.mod (BuildRealProcedureCall): Add parameter
to BuildRealFuncProcCall.
(BuildRealFuncProcCall): Add ConstExpr parameter.  Pass ConstExpr
to BuildFunctionCall.
(BuildFunctionCall): Add parameter ConstExpr.  Pass ConstExpr to
BuildRealFunctionCall.
(BuildConstFunctionCall): Add parameter ConstExpr.  Pass ConstExpr to
BuildFunctionCall.
(BuildRealFunctionCall): Add parameter ConstExpr.  Pass ConstExpr to
BuildRealFuncProcCall.
* gm2-compiler/P3Build.bnf (SetOrDesignatorOrFunction): Pass FALSE
to BuildFunctionCall.
(AssignmentOrProcedureCall): Pass FALSE to BuildFunctionCall.
* gm2-compiler/SymbolTable.def (IsProcedureBuiltinAvailable): New
procedure function.
* gm2-compiler/SymbolTable.mod (CanUseBuiltin): New procedure
function.
(IsProcedureBuiltinAvailable): New procedure function.
* gm2-gcc/m2builtins.cc (DEBUGGING): Undef.
(bf_category): New enum type.
(struct builtin_function_entry): New field function_avail.
(m2builtins_BuiltInMemCopy): Rename from ...
(m2builtins_BuiltinMemCopy): ... this.
(DoBuiltinMemSet): New function.
(m2builtins_BuiltinMemSet): New function.
(do_target_support_exists): New function.
(target_support_exists): New function.
(m2builtins_BuiltinExists): Return true or false.
(m2builtins_BuildBuiltinTree): Rename local variables.
Replace long_double_type_node with GetM2LongRealType.
(m2builtins_init): Use GetM2LongRealType rather than
long_double_type_node.
* gm2-gcc/m2builtins.def (BuiltInMemCopy): Rename to ...
(BuiltinMemCopy): ... this.
(BuiltinMemSet): New procedure function.
* gm2-gcc/m2builtins.h (m2builtins_BuiltInMemCopy): Rename to ...
(m2builtins_BuiltinMemCopy): ... this.
(m2builtins_BuiltinMemSet): New procedure function.
* gm2-gcc/m2configure.cc (m2configure_M2CLongRealFloat128): New
procedure function.
(m2configure_M2CLongRealIBM128): New procedure function.
(m2configure_M2CLongRealLongDouble): New procedure function.
(m2configure_M2CLongRealLongDoublePPC64LE): New procedure function.
* gm2-gcc/m2configure.def (M2CLongRealFloat128): New procedure function.
(M2CLongRealIBM128): New procedure function.
(M2CLongRealLongDouble): New procedure function.
(M2CLongRealLongDoublePPC64LE): New procedure function.
* gm2-gcc/m2configure.h (m2configure_FullPathCPP): New procedure function.
(m2configure_M2CLongRealFloat128): New procedure function.
(m2configure_M2CLongRealIBM128): New procedure function.
(m2configure_M2CLongRealLongDouble): New procedure function.
(m2configure_M2CLongRealLongDoublePPC64LE): New procedure function.
* gm2-gcc/m2convert.cc (m2convert_BuildConvert): Use convert_loc.
* gm2-gcc/m2options.h (M2Options_SetDebugBuiltins): New function.
* gm2-gcc/m2statement.cc (m2statement_BuildAssignmentTree): Set
TREE_USED to true.
(m2statement_BuildGoto):Set TREE_USED to true.
(m2statement_BuildParam): Set TREE_USED to true.
(m2statement_BuildBuiltinCallTree): New function.
(m2statement_BuildFunctValue): Set TREE_USED to true.
* gm2-gcc/m2statement.def (BuildBuiltinCallTree): New procedure function.
* gm2-gcc/m2statement.h (m2statement_BuildBuiltinCallTree): New
procedure function.
* gm2-gcc/m2treelib.cc (m2treelib_DoCall0): Remove spacing.
(m2treelib_DoCall1): Remove spacing.
(m2treelib_DoCall2): Remove spacing.
(m2treelib_DoCall3): Remove spacing.
(add_stmt): Rename parameter.
* gm2-gcc/m2type.cc (build_set_type): Remove spacing.
(build_m2_specific_size_type): Remove spacing.
(finish_build_pointer_type): Remove spacing.
(m2type_BuildVariableArrayAndDeclare): Remove spacing.
(build_m2_short_real_node): Remove spacing.
(build_m2_real_node): Remove spacing.
(build_m2_long_real_node): Use float128_type_node if
M2CLongRealFloat128 is set.
(build_m2_ztype_node): Remove spacing.
(build_m2_long_int_node): Remove spacing.
(build_m2_long_card_node): Remove spacing.
(build_m2_short_int_node): Remove spacing.
(build_m2_short_card_node): Remove spacing.
(build_m2_iso_loc_node): Remove spacing.
(m2type_SameRealType): New function.
(m2type_InitBaseTypes): Create m2_c_type_node using
m2_long_complex_type_node.
(m2type_SetAlignment): Tidy up comment.
* gm2-gcc/m2type.def (SameRealType):  New procedure function.
* gm2-gcc/m2type.h (m2type_SameRealType): New procedure function.
* gm2-lang.cc (gm2_langhook_type_for_mode): Build long complex
node from m2 language specific long double node.
* gm2-libs-log/RealConversions.mod (IsNan): New procedure
function.
(doPowerOfTen): Re-implement.
* gm2-libs/Builtins.mod: Add newline.
* gm2-libs/DynamicStrings.def (ReplaceChar): New procedure function.
* gm2-libs/DynamicStrings.mod (ReplaceChar): New procedure function.
* gm2config.aci.in (M2C_LONGREAL_FLOAT128): New config value.
(M2C_LONGREAL_PPC64LE): New config value.
* gm2spec.cc (lang_specific_driver): New local variable
need_default_mabi set to default value depending upon
M2C_LONGREAL_PPC64LE and M2C_LONGREAL_FLOAT128.
* lang.opt (Wcase-enum): Moved to correct section.
* m2pp.cc (m2pp_real_type): New function.
(m2pp_type): Call m2pp_real_type.
(m2pp_print_mode): New function.
(m2pp_simple_type): Call m2pp_simple_type.
(m2pp_float): New function.
(m2pp_expression): Call m2pp_float.
* mc-boot/GDynamicStrings.cc: Rebuild.
* mc-boot/GDynamicStrings.h: Rebuild.
* mc-boot/GFIO.cc: Rebuild.
* mc-boot/GFIO.h: Rebuild.
* mc-boot/GIO.cc: Rebuild.
* mc-boot/GRTint.cc: Rebuild.
* mc-boot/Gdecl.cc: Rebuild.
* mc-boot/GmcOptions.cc: Rebuild.
* mc-boot/GmcOptions.h: Rebuild.
* mc/decl.mod: Rebuild.
* mc/mcOptions.def (getCRealType): New procedure function.
(getCLongRealType): New procedure function.
(getCShortRealType): New procedure function.
* mc/mcOptions.mod (getCRealType): New procedure function.
(getCLongRealType): New procedure function.
(getCShortRealType): New procedure function.

libgm2/ChangeLog:

* Makefile.am (TARGET_LONGDOUBLE_ABI): New variable set to
-mabi=ieeelongdouble if the target is powerpc64le.
(AM_MAKEFLAGS): Append TARGET_LONGDOUBLE_ABI.
* Makefile.in: Rebuild.
* libm2cor/Makefile.am (AM_MAKEFLAGS): Add CFLAGS_LONGDOUBLE and
TARGET_LONGDOUBLE_ABI.
(libm2cor_la_CFLAGS): Add TARGET_LONGDOUBLE_ABI.
(libm2cor_la_M2FLAGS): Add TARGET_LONGDOUBLE_ABI.
* libm2cor/Makefile.in: Rebuild.
* libm2iso/Makefile.am (AM_MAKEFLAGS): Add CFLAGS_LONGDOUBLE and
TARGET_LONGDOUBLE_ABI.
(libm2iso_la_CFLAGS): Add TARGET_LONGDOUBLE_ABI.
(libm2iso_la_M2FLAGS): Add TARGET_LONGDOUBLE_ABI.
* libm2iso/Makefile.in: Rebuild.
* libm2log/Makefile.am (AM_MAKEFLAGS): Add CFLAGS_LONGDOUBLE and
TARGET_LONGDOUBLE_ABI.
(libm2log_la_CFLAGS): Add TARGET_LONGDOUBLE_ABI.
(libm2log_la_M2FLAGS): Add TARGET_LONGDOUBLE_ABI.
* libm2log/Makefile.in: Rebuild.
* libm2min/Makefile.am (AM_MAKEFLAGS): Add CFLAGS_LONGDOUBLE and
TARGET_LONGDOUBLE_ABI.
(libm2min_la_CFLAGS): Add TARGET_LONGDOUBLE_ABI.
(libm2min_la_M2FLAGS): Add TARGET_LONGDOUBLE_ABI.
* libm2min/Makefile.in: Rebuild.
* libm2pim/Makefile.am (AM_MAKEFLAGS): Add CFLAGS_LONGDOUBLE and
TARGET_LONGDOUBLE_ABI.
(libm2pim_la_CFLAGS): Add TARGET_LONGDOUBLE_ABI.
(libm2pim_la_M2FLAGS): Add TARGET_LONGDOUBLE_ABI.
* libm2pim/Makefile.in: Rebuild.

gcc/testsuite/ChangeLog:

* gm2/extensions/pass/libc.def: Add spacing.
* gm2/pimlib/logitech/run/pass/realconv.mod: Add debugging print.
* gm2/switches/uninit-variable-checking/cascade/fail/switches-uninit-variable-checking-cascade-fail.exp:
Add -fdebug-builtins flag.
* lib/gm2.exp (gm2_target_compile_default): Add
-mabi=ieeelongdouble if the target is powerpc.
(gm2_link_flags): Add
-mabi=ieeelongdouble if the target is powerpc.
* gm2/pim/intrinsic/run/pass/cstub.c: New test.
* gm2/pim/intrinsic/run/pass/cstub.def: New test.
* gm2/pim/intrinsic/run/pass/pim-intrinsic-run-pass.exp: New test.
* gm2/pim/intrinsic/run/pass/test.mod: New test.
* gm2/pim/run/pass/builtins.mod: New test.
* gm2/pim/run/pass/convert1.mod: New test.
* gm2/pim/run/pass/longint1.mod: New test.
* gm2/pim/run/pass/longint2.mod: New test.
* gm2/pim/run/pass/longint3.mod: New test.
* gm2/pim/run/pass/longint4.mod: New test.
* gm2/pim/run/pass/longint5.mod: New test.
* gm2/pim/run/pass/longint6.mod: New test.
* gm2/pim/run/pass/longint7.mod: New test.
* gm2/pim/run/pass/longint8.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
10 months agoFix bogus operand predicate on iq2000
Jeff Law [Tue, 19 Sep 2023 17:28:53 +0000 (11:28 -0600)]
Fix bogus operand predicate on iq2000

The iq2000-elf port regressed these tests recently:

> iq2000-sim: gcc.c-torture/execute/20040703-1.c   -O2  (test for excess errors)
> iq2000-sim: gcc.c-torture/execute/20040703-1.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  (test for excess errors)
> iq2000-sim: gcc.c-torture/execute/20040703-1.c   -O3 -g  (test for excess errors)

It turns out one of the patterns had an operand predicate that allowed REG,
SUBREG, CONST_INT (with a limited set of CONST_INTs).  Yet the constraint only
allowed the limited set of immediates.  This naturally triggered an LRA
constraint failure.

The fix is trivial, create an operand predicate that accurately reflects the
kinds of operands allowed by the instruction.

It turns out this was a long standing bug -- fixing the pattern resolved 55
failing tests in the testsuite.

gcc/
* config/iq2000/predicates.md (uns_arith_constant): New predicate.
* config/iq2000/iq2000.md (rotrsi3): Use it.

10 months agofortran: fix checking of CHARACTER lengths in array constructors [PR70231]
Harald Anlauf [Mon, 18 Sep 2023 20:11:40 +0000 (22:11 +0200)]
fortran: fix checking of CHARACTER lengths in array constructors [PR70231]

gcc/fortran/ChangeLog:

PR fortran/70231
* trans-array.cc (trans_array_constructor): In absence of a typespec,
use string length determined by get_array_ctor_strlen() to reasonably
initialize auxiliary variable for bounds-checking.

gcc/testsuite/ChangeLog:

PR fortran/70231
* gfortran.dg/bounds_check_fail_7.f90: New test.

10 months ago[frange] Remove redundant known_isnan() checks.
Aldy Hernandez [Tue, 19 Sep 2023 01:45:35 +0000 (21:45 -0400)]
[frange] Remove redundant known_isnan() checks.

The known_isnan() method is a subset of maybe_isnan().  This patch
removes redundant calls to known_isnan().

gcc/ChangeLog:

* range-op-float.cc (operator_lt::op1_range): Remove known_isnan check.
(operator_lt::op2_range): Same.
(operator_le::op1_range): Same.
(operator_le::op2_range): Same.
(operator_gt::op1_range): Same.
(operator_gt::op2_range): Same.
(operator_ge::op1_range): Same.
(operator_ge::op2_range): Same.
(foperator_unordered_lt::op1_range): Same.
(foperator_unordered_lt::op2_range): Same.
(foperator_unordered_le::op1_range): Same.
(foperator_unordered_le::op2_range): Same.
(foperator_unordered_gt::op1_range): Same.
(foperator_unordered_gt::op2_range): Same.
(foperator_unordered_ge::op1_range): Same.
(foperator_unordered_ge::op2_range): Same.

10 months agoAdd frange::update_nan (const nan_state &).
Aldy Hernandez [Mon, 18 Sep 2023 15:39:32 +0000 (11:39 -0400)]
Add frange::update_nan (const nan_state &).

We can set_nan() with a nan_state so it's good form to have the
analogous form for update_nan().

gcc/ChangeLog:

* value-range.h (frange::update_nan): New.

10 months ago[frange] Add op2_range for operator_not_equal.
Aldy Hernandez [Fri, 15 Sep 2023 12:24:24 +0000 (08:24 -0400)]
[frange] Add op2_range for operator_not_equal.

We're missing an op2_range entry for operator_not_equal so GORI can
calculate an outgoing edge.  The false side of != is true and
guarantees we don't have a NAN, so it's important to get this right.
We eventually get it through an intersection of various ranges in
ranger, but it's best to get things correct as early as possible.

gcc/ChangeLog:

* range-op-float.cc (operator_not_equal::op2_range): New.
* range-op-mixed.h: Add operator_not_equal::op2_range.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/vrp-float-13.c: New test.

10 months agotestsuite work-around compound-assignment-1.c C++ failures on various targets [PR111377]
Jakub Jelinek [Tue, 19 Sep 2023 15:48:42 +0000 (17:48 +0200)]
testsuite work-around compound-assignment-1.c C++ failures on various targets [PR111377]

On Mon, Sep 11, 2023 at 11:11:30PM +0200, Jakub Jelinek via Gcc-patches wrote:
> I think the divergence is whether called_by_test_5b returns the struct
> in registers or in memory.  If in memory (like in the x86_64 -m32 case), we have
>   [compound-assignment-1.c:71:21] D.3191 = called_by_test_5b (); [return slot optimization]
>   [compound-assignment-1.c:71:21 discrim 1] D.3191 ={v} {CLOBBER(eol)};
>   [compound-assignment-1.c:72:1] return;
> in the IL, while if in registers (like x86_64 -m64 case), just
>   [compound-assignment-1.c:71:21] D.3591 = called_by_test_5b ();
>   [compound-assignment-1.c:72:1] return;
>
> If you just want to avoid the differences, putting } on the same line as the
> call might be a usable workaround for that.

Here is the workaround in patch form.

2023-09-19  Jakub Jelinek  <jakub@redhat.com>

PR testsuite/111377
* c-c++-common/analyzer/compound-assignment-1.c (test_5b): Move
closing } to the same line as the call to work-around differences in
diagnostics line.

10 months agoc++: inherited default constructor [CWG2799]
Jason Merrill [Tue, 19 Sep 2023 02:16:04 +0000 (22:16 -0400)]
c++: inherited default constructor [CWG2799]

In this testcase, it seems clear that B should be trivially
default-constructible, since the inherited default constructor is trivial
and there are no other subobjects to initialize.  But we were saying no
because we don't define triviality of inherited constructors.

CWG discussion suggested that the solution is to implicitly declare a
default constructor when inheriting a default constructor; that makes sense
to me.

DR 2799

gcc/cp/ChangeLog:

* class.cc (add_implicit_default_ctor): Split out...
(add_implicitly_declared_members): ...from here.
Also call it when inheriting a default ctor.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/inh-ctor38.C: New test.

10 months agoNew early __builtin_unreachable processing.
Andrew MacLeod [Wed, 13 Sep 2023 15:52:15 +0000 (11:52 -0400)]
New early __builtin_unreachable processing.

in VRP passes before __builtin_unreachable MUST be removed, only remove it
if all exports affected by the unreachable can have global values updated, and
do not involve loads from memory.

PR tree-optimization/110080
PR tree-optimization/110249
gcc/
* tree-vrp.cc (remove_unreachable::final_p): New.
(remove_unreachable::maybe_register): Rename from
maybe_register_block and call early or final routine.
(fully_replaceable): New.
(remove_unreachable::handle_early): New.
(remove_unreachable::remove_and_update_globals): Remove
non-final processing.
(rvrp_folder::rvrp_folder): Add final flag to constructor.
(rvrp_folder::post_fold_bb): Remove unreachable registration.
(rvrp_folder::pre_fold_stmt): Move unreachable processing to here.
(execute_ranger_vrp): Adjust some call parameters.

gcc/testsuite/
* g++.dg/pr110249.C: New.
* gcc.dg/pr110080.c: New.
* gcc.dg/pr93917.c: Adjust.

10 months agoc++: Move consteval folding to cp_fold_r
Marek Polacek [Fri, 1 Sep 2023 00:11:50 +0000 (20:11 -0400)]
c++: Move consteval folding to cp_fold_r

In the review of P2564:
<https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628747.html>
it turned out that in order to correctly handle an example in the paper,
we should stop doing immediate evaluation in build_over_call and
bot_replace, and instead do it in cp_fold_r.  This patch does that.

Another benefit is that this is a pretty significant simplification, at
least in my opinion.  Also, this fixes the c++/110997 ICE (but the test
doesn't compile yet).

The main drawback seems to be that cp_fold_r doesn't process
uninstantiated templates.  We still have to handle things like
"false ? foo () : 1".  To that end, I've added cp_fold_immediate, called
on dead branches in cxx_eval_conditional_expression.

You'll see that I've reintroduced ADDR_EXPR_DENOTES_CALL_P here.  This
is to detect

  *(&foo)) ()
  (s.*&S::foo) ()

which were deemed ill-formed.

gcc/cp/ChangeLog:

* call.cc (build_over_call): Set ADDR_EXPR_DENOTES_CALL_P.  Don't handle
immediate_invocation_p here.
* constexpr.cc (cxx_eval_call_expression): Use mce_true for
DECL_IMMEDIATE_FUNCTION_P.
(cxx_eval_conditional_expression): Call cp_fold_immediate.
* cp-gimplify.cc (enum fold_flags): Add ff_fold_immediate.
(maybe_replace_decl): Make static.
(cp_fold_r): Expand immediate invocations.
(cp_fold_immediate_r): New.
(cp_fold_immediate): New.
* cp-tree.h (ADDR_EXPR_DENOTES_CALL_P): Define.
(cp_fold_immediate): Declare.
* tree.cc (bot_replace): Don't handle immediate invocations here.

libstdc++-v3/ChangeLog:

* testsuite/20_util/allocator/105975.cc: Add dg-error.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/consteval-if2.C: Add xfail.
* g++.dg/cpp2a/consteval-memfn1.C: Adjust.
* g++.dg/cpp2a/consteval11.C: Remove dg-message.
* g++.dg/cpp2a/consteval3.C: Remove dg-message and dg-error.
* g++.dg/cpp2a/consteval9.C: Remove dg-message.
* g++.dg/cpp2a/consteval32.C: New test.
* g++.dg/cpp2a/consteval33.C: New test.
* g++.dg/cpp2a/consteval34.C: New test.
* g++.dg/cpp2a/consteval35.C: New test.

10 months agoc/111468 - dump unordered compare operators in their GIMPLE form with -gimple
Richard Biener [Tue, 19 Sep 2023 11:18:51 +0000 (13:18 +0200)]
c/111468 - dump unordered compare operators in their GIMPLE form with -gimple

The following adjusts -gimple dumping to dump the unordered compare ops
and *h in their GIMPLE form.  It also adds parsing for __LTGT which I
missed before.

PR c/111468
gcc/c/
* gimple-parser.cc (c_parser_gimple_binary_expression): Handle __LTGT.

gcc/
* tree-pretty-print.h (op_symbol_code): Add defaulted flags
argument.
* tree-pretty-print.cc (op_symbol): Likewise.
(op_symbol_code): Print TDF_GIMPLE variant if requested.
* gimple-pretty-print.cc (dump_binary_rhs): Pass flags to
op_symbol_code.
(dump_gimple_cond): Likewise.

gcc/testsuite/
* gcc.dg/gimplefe-50.c: Amend.

10 months agoc++: overeager type completion in convert_to_void [PR111419]
Patrick Palka [Tue, 19 Sep 2023 12:29:39 +0000 (08:29 -0400)]
c++: overeager type completion in convert_to_void [PR111419]

Here convert_to_void always completes the type of an indirection or
id-expression, but according to [expr.context] an lvalue-to-rvalue
conversion is applied to a discarded-value expression only if "the
expression is a glvalue of volatile-qualified type".  This patch
restricts convert_to_void's type completion to match.

PR c++/111419

gcc/cp/ChangeLog:

* cvt.cc (convert_to_void) <case INDIRECT_REF>: Only call
complete_type if the type is volatile.
<case VAR_DECL>: Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-requires36.C: New test.
* g++.dg/expr/discarded1.C: New test.
* g++.dg/expr/discarded1a.C: New test.

10 months agoc++: constness of decltype of NTTP object [PR99631]
Patrick Palka [Tue, 19 Sep 2023 12:21:05 +0000 (08:21 -0400)]
c++: constness of decltype of NTTP object [PR99631]

This corrects resolving decltype of a (class) NTTP object as per
[dcl.type.decltype]/1.2 and [temp.param]/6 in the type-dependent case.

Note that in the non-dependent case we resolve the decltype ahead of
time, in which case finish_decltype_type drops the const VIEW_CONVERT_EXPR
wrapper around the TEMPLATE_PARM_INDEX, and the latter has the desired
non-const type.

In the type-dependent case, at instantiation time tsubst drops the
VIEW_CONVERT_EXPR since the substituted NTTP is the already-const object
created by get_template_parm_object.  So in this case finish_decltype_type
sees the const object, which this patch now adds special handling for.

PR c++/99631

gcc/cp/ChangeLog:

* semantics.cc (finish_decltype_type): For an NTTP object,
return its type modulo cv-quals.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/nontype-class60.C: New test.

10 months agoRISC-V: Add FNMS floating-point VLS tests
Juzhe-Zhong [Tue, 19 Sep 2023 11:33:12 +0000 (19:33 +0800)]
RISC-V: Add FNMS floating-point VLS tests

Add tests and committed.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/def.h: Add FNMS VLS modes tests.
* gcc.target/riscv/rvv/autovec/vls/fnms-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/fnms-2.c: New test.
* gcc.target/riscv/rvv/autovec/vls/fnms-3.c: New test.

10 months agoLTO: Get rid of 'lto_mode_identity_table'
Thomas Schwinge [Thu, 10 Aug 2023 13:23:37 +0000 (15:23 +0200)]
LTO: Get rid of 'lto_mode_identity_table'

This, in particular, resolves LTO ICEs with big 'machine_mode's, as for RISC-V.
('mode_table' in 'lto_file_decl_data' still is 'unsigned char'; changing that
is still to be done (for use in offloading compilation), but is not trivial.)
For now, get rid of 'lto_mode_identity_table' to resolve the RISC-V LTO ICEs;
we don't need an actual table for a 1-to-1 mapping.

gcc/lto/
* lto-common.cc (lto_mode_identity_table): Remove.
(lto_file_finalize) [!ACCEL_COMPILER]: 'NULL'-intialize
'file_data->mode_table'.
(lto_fe_init): Don't initialize 'lto_mode_identity_table'.
* lto-common.h (lto_mode_identity_table): Remove.
gcc/
* tree-streamer.h (bp_unpack_machine_mode): If
'ib->file_data->mode_table' not available, apply 1-to-1 mapping.

Co-authored-by: Pan Li <pan2.li@intel.com>
10 months agoRISC-V: Fix RVV can change mode class bug
Juzhe-Zhong [Tue, 19 Sep 2023 02:59:22 +0000 (10:59 +0800)]
RISC-V: Fix RVV can change mode class bug

After support the VLS mode conversion, current case triggers a latent bug that we are
lucky we didn't encounter.

This is a real bug in 'cprop_hardreg':

orig:RVVMF8BI,16,16
new:V32BI,32,0
during RTL pass: cprop_hardreg
auto.c: In function 'main':
auto.c:79:1: internal compiler error: in partial_subreg_p, at rtl.h:3186
   79 | }
      | ^
0x10979a7 partial_subreg_p(machine_mode, machine_mode)
        ../../../../gcc/gcc/rtl.h:3186
0x1723eda mode_change_ok
        ../../../../gcc/gcc/regcprop.cc:402
0x1724007 maybe_mode_change
        ../../../../gcc/gcc/regcprop.cc:436
0x172445d find_oldest_value_reg
        ../../../../gcc/gcc/regcprop.cc:489
0x172534d copyprop_hardreg_forward_1
        ../../../../gcc/gcc/regcprop.cc:808
0x1727017 cprop_hardreg_bb
        ../../../../gcc/gcc/regcprop.cc:1358
0x17272f7 execute
        ../../../../gcc/gcc/regcprop.cc:1425

When trying to do reg copy propagation between RVVMF8BI (precision = 16,16)
and V32BI (precision = 32,0).

The assertion failed in partial_subreg_p:
gcc_checking_assert (ordered_p (outer_prec, inner_prec));

In regcprop.cc:

  if (partial_subreg_p (orig_mode, new_mode))
    return false;

If orig_mode (RVVMF8BI) smaller than new_mode (V32BI), we don't do the hard reg propogation.
However, the 'partial_subreg_p' cause ICE since gcc_checking_assert (ordered_p (outer_prec, inner_prec)).

After analysis in aarch64.cc, they do careful block in 'TARGET_CAN_CHANGE_MODE_CLASS'.
So it's reasonable block regcprop when old mode size maybe_lt than new mode size since we won't do the
copy propgation.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_can_change_mode_class): Block unordered VLA and VLS modes.

10 months agoada: TSS finalize address subprogram generation for constrained...
Richard Wai [Sun, 17 Sep 2023 15:00:00 +0000 (11:00 -0400)]
ada: TSS finalize address subprogram generation for constrained...

...subtypes of unconstrained synchronized private extensions should take
care to designate the corresponding record of the underlying concurrent
type.

When generating TSS finalize address subprograms for class-wide types of
constrained root types, it follows the parent chain looking for the
first "non-constrained" type. It is possible that such a type is a
private extension with the “synchronized” keyword, in which case the
underlying type is a concurrent type. When that happens, the designated
type of the finalize address subprogram should be the corresponding
record’s class-wide-type.

gcc/ada/ChangeLog:
* exp_ch3.adb (Expand_Freeze_Class_Wide_Type): Expanded comments
explaining why TSS Finalize_Address is not generated for
concurrent class-wide types.
* exp_ch7.adb (Make_Finalize_Address_Stmts): Handle cases where the
underlying non-constrained parent type is a concurrent type, and
adjust the designated type to be the corresponding record’s
class-wide type.

gcc/testsuite/ChangeLog:

* gnat.dg/sync_tag_finalize.adb: New test.

Signed-off-by: Richard Wai <richard@annexi-strayline.com>
10 months agoada: Private extensions with the keyword "synchronized" are always limited.
Richard Wai [Wed, 9 Aug 2023 05:54:48 +0000 (01:54 -0400)]
ada: Private extensions with the keyword "synchronized" are always limited.

GNAT was relying on synchronized private type extensions deriving from a
concurrent interface to determine its limitedness. This does not cover the case
where such an extension derives a limited interface. RM-7.6(6/2) makes is clear
that "synchronized" in a private extension implies the derived type is limited.
GNAT should explicitly check for the presence of "synchronized" in a private
extension declaration, and it should have the same effect as the presence of
“limited”.

gcc/ada/ChangeLog:

* sem_ch3.adb (Build_Derived_Record_Type): Treat presence of
keyword "synchronized" the same as "limited" when determining if a
private extension is limited.

gcc/testsuite/ChangeLog:

* gnat.dg/sync_tag_discriminals.adb: New test.
* gnat.dg/sync_tag_limited.adb: New test.

Signed-off-by: Richard Wai <richard@annexi-strayline.com>
10 months agoRISC-V: Support VLS unary floating-point patterns
Juzhe-Zhong [Tue, 19 Sep 2023 11:01:24 +0000 (19:01 +0800)]
RISC-V: Support VLS unary floating-point patterns

Extend current VLA patterns with VLS modes.

Regression all passed.

gcc/ChangeLog:

* config/riscv/autovec.md: Extend VLS modes.
* config/riscv/vector.md: Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vls/def.h: Add unary test.
* gcc.target/riscv/rvv/autovec/vls/neg-2.c: New test.

10 months agoada: Refine upper array bound for bit packed array
Marc Poulhiès [Fri, 8 Sep 2023 15:15:48 +0000 (15:15 +0000)]
ada: Refine upper array bound for bit packed array

When using bit-packed arrays, the compiler creates new array subtypes of
1-bit component indexed by integers. The existing routine checks the
index subtype to find the min/max values. Bit-packed arrays being
indexed by integers, the routines gives up as returning the maximum
possible integer carries no useful information.

This change adds a simple max_value routine that can evaluate very
simple expressions by substituting variables by their min/max value.
Bit-packed array subtypes are currently declared as:

  subtype bp_array is packed_bytes1 (0 .. integer((1 * Var +  7) / 8 - 1));

The simple max_value evaluator handles the bare minimum for this
expression pattern.

gcc/ada/ChangeLog:

* gcc-interface/utils.cc (max_value): New.
* gcc-interface/gigi.h (max_value): New.
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Array_Subtype>:
When computing gnu_min/gnu_max, try to use max_value if there is
an initial expression.

10 months agoada: Crash processing type invariants on child subprogram
Javier Miranda [Fri, 8 Sep 2023 11:53:44 +0000 (11:53 +0000)]
ada: Crash processing type invariants on child subprogram

gcc/ada/

* contracts.adb
(Has_Public_Visibility_Of_Subprogram): Add missing support for
child subprograms.

10 months agotree-optimization/111465 - bougs jump threading with no-copy src block
Richard Biener [Tue, 19 Sep 2023 10:36:04 +0000 (12:36 +0200)]
tree-optimization/111465 - bougs jump threading with no-copy src block

The following avoids to forward thread a path with a EDGE_NO_COPY_SRC_BLOCK
block that became non-empty due to folding.

PR tree-optimization/111465
* tree-ssa-threadupdate.cc (fwd_jt_path_registry::thread_block_1):
Cancel the path when a EDGE_NO_COPY_SRC_BLOCK became non-empty.

* g++.dg/torture/pr111465.C: New testcase.

10 months agoc/111468 - add unordered compare and pointer diff to GIMPLE FE parsing
Richard Biener [Tue, 19 Sep 2023 09:49:54 +0000 (11:49 +0200)]
c/111468 - add unordered compare and pointer diff to GIMPLE FE parsing

The following adds __UN{LT,LE,GT,GE,EQ}, __UNORDERED and __ORDERED
operator parsing support and support for parsing - as POINTER_DIFF_EXPR.

PR c/111468
gcc/c/
* gimple-parser.cc (c_parser_gimple_binary_expression): Add
return type argument.
(c_parser_gimple_statement): Adjust.
(c_parser_gimple_paren_condition): Likewise.
(c_parser_gimple_binary_expression): Use passed in return type,
add support for - as POINTER_DIFF_EXPR, __UN{LT,LE,GT,GE,EQ},
__UNORDERED and __ORDERED.

gcc/testsuite/
* gcc.dg/gimplefe-50.c: New testcase.
* gcc.dg/gimplefe-51.c: Likewise.

This page took 0.133896 seconds and 5 git commands to generate.