[PATCH v3] x86: Properly find the maximum stack slot alignment

2023-07-24 Thread H.J. Lu via Gcc-patches
Don't assume that stack slots can only be accessed by stack or frame registers. We first find all registers defined by stack or frame registers. Then check memory accesses by such registers, including stack and frame registers. gcc/ PR target/109780 * config/i386/i386.cc

Re: [PATCH v2] x86: Properly find the maximum stack slot alignment

2023-07-24 Thread H.J. Lu via Gcc-patches
On Mon, Jul 10, 2023 at 3:32 AM Richard Biener wrote: > > On Fri, Jul 7, 2023 at 5:14 PM H.J. Lu via Gcc-patches > wrote: > > > > Don't assume that stack slots can only be accessed by stack or frame > > registers. We first find all registers defined by stack or frame

[PATCH v2] x86: Properly find the maximum stack slot alignment

2023-07-07 Thread H.J. Lu via Gcc-patches
Don't assume that stack slots can only be accessed by stack or frame registers. We first find all registers defined by stack or frame registers. Then check memory accesses by such registers, including stack and frame registers. gcc/ PR target/109780 * config/i386/i386.cc

[PATCH] x86: Properly find the maximum stack slot alignment

2023-07-05 Thread H.J. Lu via Gcc-patches
Don't assume that stack slots can only be accessed by stack or frame registers. Also check memory accesses from registers defined by stack or frame registers. gcc/ PR target/109780 * config/i386/i386.cc (ix86_set_with_register_source): New. (ix86_find_all_stack_access):

Re: [PATCH] i386: Honour -mdirect-extern-access when calling __fentry__

2023-05-10 Thread H.J. Lu via Gcc-patches
On Wed, May 10, 2023 at 2:17 AM Uros Bizjak wrote: > > On Tue, May 9, 2023 at 10:58 AM Ard Biesheuvel wrote: > > > > The small and medium PIC code models generate profiling calls that > > always load the address of __fentry__() via the GOT, even if > > -mdirect-extern-access is in effect. > > >

Re: [PATCH] libsanitizer: cherry-pick commit 05551c658269 from upstream

2023-04-27 Thread H.J. Lu via Gcc-patches
On Thu, Apr 27, 2023 at 12:03 AM Martin Liška wrote: > > On 4/27/23 04:32, H.J. Lu via Gcc-patches wrote: > > cherry-pick: > > Can you please wait a few days before it? I'm going to merge again > in the near future after https://reviews.llvm.org/D144073 got hand

[PATCH] libsanitizer: cherry-pick commit 05551c658269 from upstream

2023-04-26 Thread H.J. Lu via Gcc-patches
cherry-pick: 05551c658269 [sanitizer] Correct alignment of x32 __sanitizer_siginfo * sanitizer_common/sanitizer_platform_limits_posix.h (__sanitizer_siginfo_pad): Use u64 to align x32 __sanitizer_siginfo to 8 bytes. ---

Re: libsanitizer: sync from master

2023-04-26 Thread H.J. Lu via Gcc-patches
On Wed, Apr 26, 2023 at 4:37 PM H.J. Lu wrote: > > On Wed, Apr 26, 2023 at 1:24 PM Martin Liška wrote: > > > > On 4/26/23 21:23, H.J. Lu wrote: > > > On Wed, Apr 26, 2023 at 6:52 AM Martin Liška wrote: > > >> > > >> On 11/15/22 16:47, Martin Liška wrote: > > >>> Hi. > > >>> > > >>> I've just

Re: libsanitizer: sync from master

2023-04-26 Thread H.J. Lu via Gcc-patches
On Wed, Apr 26, 2023 at 1:24 PM Martin Liška wrote: > > On 4/26/23 21:23, H.J. Lu wrote: > > On Wed, Apr 26, 2023 at 6:52 AM Martin Liška wrote: > >> > >> On 11/15/22 16:47, Martin Liška wrote: > >>> Hi. > >>> > >>> I've just pushed libsanitizer update that was tested on x86_64-linux and > >>>

Re: libsanitizer: sync from master

2023-04-26 Thread H.J. Lu via Gcc-patches
On Wed, Apr 26, 2023 at 6:52 AM Martin Liška wrote: > > On 11/15/22 16:47, Martin Liška wrote: > > Hi. > > > > I've just pushed libsanitizer update that was tested on x86_64-linux and > > ppc64le-linux systems. > > Moreover, I run bootstrap on x86_64-linux and checked ABI difference with > >

Re: [PATCH] Remove TARGET_GEN_MEMSET_SCRATCH_RTX since it's not used anymore.

2023-03-22 Thread H.J. Lu via Gcc-patches
On Wed, Mar 22, 2023 at 3:19 AM Richard Biener wrote: > > On Wed, Mar 22, 2023 at 8:07 AM Uros Bizjak wrote: > > > > On Wed, Mar 22, 2023 at 3:59 AM liuhongt wrote: > > > > > > The target hook is only used by i386, and the current definition is > > > same as default gen_reg_rtx. So there's no

Re: [PATCH] i386: Call get_available_features for all CPUs with max_level >= 1 [PR100758]

2023-02-09 Thread H.J. Lu via Gcc-patches
On Thu, Feb 9, 2023 at 4:12 AM Jakub Jelinek wrote: > > Hi! > > get_available_features doesn't depend on cpu_model2->__cpu_{family,model} > and just sets stuff up based on CPUID leaf 1, or some extended ones, > so I wonder why are we calling it separately for Intel, AMD and Zhaoxin > and not for

[PATCH] libsanitizer: cherry-pick commit 742bcbf685bc from upstream

2023-01-31 Thread H.J. Lu via Gcc-patches
cherry-pick: 742bcbf685bc compiler-rt/lib: Add .Linterceptor_sigsetjmp PR sanitizer/108106 * hwasan/hwasan_setjmp_x86_64.S (__interceptor_setjmp): Jump to .Linterceptor_sigsetjmp instead of __interceptor_sigsetjmp. (__interceptor_sigsetjmp): Add a local alias,

[PATCH] x86: Check invalid third argument to __builtin_ia32_prefetch

2023-01-18 Thread H.J. Lu via Gcc-patches
Check invalid third argument to __builtin_ia32_prefetch when expaning __builtin_ia32_prefetch to avoid ICE later. gcc/ PR target/108436 * config/i386/i386-expand.cc (ix86_expand_builtin): Check invalid third argument to __builtin_ia32_prefetch. gcc/testsuite/ *

[PATCH] x86: Disable -mforce-indirect-call for PIC in 32-bit mode

2023-01-16 Thread H.J. Lu via Gcc-patches
-mforce-indirect-call generates invalid instruction in 32-bit MI thunk since there are no available scratch registers in 32-bit PIC mode. Disable -mforce-indirect-call for PIC in 32-bit mode when generating MI thunk. gcc/ PR target/105980 * config/i386/i386.cc

Re: [PATCH] libgfortran: Replace mutex with rwlock

2022-12-27 Thread H.J. Lu via Gcc-patches
On Sun, Dec 25, 2022 at 4:58 PM Steve Kargl via Gcc-patches wrote: > > On Wed, Dec 21, 2022 at 07:27:11PM -0500, Lipeng Zhu via Fortran wrote: > > This patch try to introduce the rwlock and split the read/write to > > unit_root tree and unit_cache with rwlock instead of the mutex to > > increase

Re: [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR.

2022-12-21 Thread H.J. Lu via Gcc-patches
On Wed, Dec 21, 2022 at 2:35 PM Jakub Jelinek wrote: > > On Wed, Dec 21, 2022 at 12:20:23PM -0800, H.J. Lu wrote: > > On Mon, Dec 19, 2022 at 8:52 PM Hongtao Liu wrote: > > > > > > On Thu, Dec 15, 2022 at 3:45 PM Hongtao Liu wrote: > > > > > > > > On Thu, Dec 15, 2022 at 3:39 PM Jakub Jelinek

Re: [PATCH V2 2/2] [x86] x86: Add a new option -mdaz-ftz to enable FTZ and DAZ flags in MXCSR.

2022-12-21 Thread H.J. Lu via Gcc-patches
On Mon, Dec 19, 2022 at 8:52 PM Hongtao Liu wrote: > > On Thu, Dec 15, 2022 at 3:45 PM Hongtao Liu wrote: > > > > On Thu, Dec 15, 2022 at 3:39 PM Jakub Jelinek wrote: > > > > > > On Thu, Dec 15, 2022 at 02:21:37PM +0800, liuhongt via Gcc-patches wrote: > > > > --- a/gcc/config/i386/i386.opt > >

[PATCH] libsanitizer: Add __interceptor_sigsetjmp_internal

2022-12-16 Thread H.J. Lu via Gcc-patches
Add an internal alias to __interceptor_sigsetjmp to avoid R_X86_64_PC32 relocation for "jmp __interceptor_sigsetjmp" with old assemblers. PR sanitizer/108106 * hwasan/hwasan_setjmp_x86_64.S (__interceptor_sigsetjmp): Add an internal alias, __interceptor_sigsetjmp_internal.

Re: [PATCH] [x86] Fix unrecognizable insn due to illegal immediate_operand (const_int 255) of QImode.

2022-11-29 Thread H.J. Lu via Gcc-patches
On Mon, Nov 28, 2022 at 11:04 PM Hongtao Liu wrote: > > On Mon, Nov 28, 2022 at 9:06 PM liuhongt wrote: > > > > For __builtin_ia32_vec_set_v16qi (a, -1, 2) with > > !flag_signed_char. it's transformed to > > __builtin_ia32_vec_set_v16qi (_4, 255, 2) in the gimple, > > and expanded to (const_int

Re: [PATCH 0/2] Support HWASAN with Intel LAM

2022-11-28 Thread H.J. Lu via Gcc-patches
On Mon, Nov 28, 2022 at 6:40 AM Martin Liška wrote: > > On 11/11/22 02:26, liuhongt via Gcc-patches wrote: > >2 years ago, ARM folks support HWASAN[1] in GCC[2], and introduced > > several > > target hooks(Many thanks to their work) so other backends can do similar > > things if they have

Re: [PATCH v4] eliminate mutex in fast path of __register_frame

2022-11-21 Thread H.J. Lu via Gcc-patches
On Mon, Nov 21, 2022 at 3:49 AM Jakub Jelinek via Gcc-patches wrote: > > On Mon, Nov 21, 2022 at 12:22:32PM +0100, Thomas Neumann via Gcc-patches > wrote: > > > When dynamically linking a fast enough machine hides the latency, but when > > > Statically linking or on slower devices this change

Re: [PATCH v2] Always use TYPE_MODE instead of DECL_MODE for vector field

2022-11-07 Thread H.J. Lu via Gcc-patches
; > > > > > On Fri, Oct 21, 2022 at 2:33 AM Richard Biener > > > > wrote: > > > > > > > > > > On Thu, Oct 20, 2022 at 6:58 PM H.J. Lu via Gcc-patches > > > > > wrote: > > > > > > >

[PATCH] Extend optimization for integer bit test on __atomic_fetch_[or|and]_*

2022-11-02 Thread H.J. Lu via Gcc-patches
Extend optimization for _1 = __atomic_fetch_or_4 (ptr_6, 0x8000, _3); _5 = (signed int) _1; _4 = _5 >= 0; to _1 = __atomic_fetch_or_4 (ptr_6, 0x8000, _3); _5 = (signed int) _1; if (_5 >= 0) gcc/ PR middle-end/102566 * tree-ssa-ccp.cc (optimize_atomic_bit_test_and):

[PATCH] x86: Track converted/skipped registers in STV

2022-10-31 Thread H.J. Lu via Gcc-patches
When converting integer computations into vector ones, we build a chain from an integer definition instruction together with all dependent use instructions. The integer computations on the chain are converted to vector ones if the total vector costs are lower than the integer ones. Since the same

Re: [PATCH] x86: Replace ne:CCC/ne:CCO with UNSPEC_CC_NE in neg patterns

2022-10-28 Thread H.J. Lu via Gcc-patches
On Fri, Oct 28, 2022 at 2:34 PM Segher Boessenkool wrote: > > On Wed, Oct 26, 2022 at 11:58:57AM -0700, H.J. Lu via Gcc-patches wrote: > > In i386.md, neg patterns which set MODE_CC register like > > > > (set (reg:CCC FLAGS_REG) > > (ne:CCC (match_operan

Re: [PATCH] x86: Replace ne:CCC/ne:CCO with UNSPEC_CC_NE in neg patterns

2022-10-28 Thread H.J. Lu via Gcc-patches
On Fri, Oct 28, 2022 at 1:35 AM Eric Botcazou wrote: > > > (set (reg:SI 93) > > (neg:SI (ltu:SI (reg:CCC 17 flags) (const_int 0 [0] > > > > as > > > > (set (reg:SI 93) > > (neg:SI (ltu:SI (const_int 1) (const_int 0 [0] > > > > which leads to incorrect results since LTU on

[PATCH] x86: Replace ne:CCC/ne:CCO with UNSPEC_CC_NE in neg patterns

2022-10-26 Thread H.J. Lu via Gcc-patches
In i386.md, neg patterns which set MODE_CC register like (set (reg:CCC FLAGS_REG) (ne:CCC (match_operand:SWI48 1 "general_reg_operand") (const_int 0))) can lead to errors when operand 1 is a constant value. If FLAGS_REG in (set (reg:CCC FLAGS_REG) (ne:CCC (const_int 2) (const_int

[PATCH v2] Always use TYPE_MODE instead of DECL_MODE for vector field

2022-10-24 Thread H.J. Lu via Gcc-patches
On Mon, Oct 24, 2022 at 12:12 AM Richard Biener wrote: > > On Fri, Oct 21, 2022 at 6:18 PM H.J. Lu wrote: > > > > On Fri, Oct 21, 2022 at 2:33 AM Richard Biener > > wrote: > > > > > > On Thu, Oct 20, 2022 at 6:58 PM H.J. Lu via Gcc-pa

Re: [PATCH] Always use TYPE_MODE instead of DECL_MODE for vector field

2022-10-21 Thread H.J. Lu via Gcc-patches
On Fri, Oct 21, 2022 at 2:33 AM Richard Biener wrote: > > On Thu, Oct 20, 2022 at 6:58 PM H.J. Lu via Gcc-patches > wrote: > > > > commit e034c5c895722e0092d2239cd8c2991db77d6d39 > > Author: Jakub Jelinek > > Date: Sat Dec 2 08:54:47 2017 +0100 > > >

[PATCH] Always use TYPE_MODE instead of DECL_MODE for vector field

2022-10-20 Thread H.J. Lu via Gcc-patches
commit e034c5c895722e0092d2239cd8c2991db77d6d39 Author: Jakub Jelinek Date: Sat Dec 2 08:54:47 2017 +0100 PR target/78643 PR target/80583 * expr.c (get_inner_reference): If DECL_MODE of a non-bitfield is BLKmode for vector field with vector raw mode, use

Re: [PATCH 2/2] Support Intel prefetchit0/t1

2022-10-19 Thread H.J. Lu via Gcc-patches
On Fri, Oct 14, 2022 at 1:38 AM Haochen Jiang via Gcc-patches wrote: > > gcc/ChangeLog: > > * common/config/i386/cpuinfo.h (get_available_features): > Detect PREFETCHI. > * common/config/i386/i386-common.cc > (OPTION_MASK_ISA2_PREFETCHI_SET, >

Re: [PATCH] Canonicalize vec_perm index to make the first index come from the first vector.

2022-10-18 Thread H.J. Lu via Gcc-patches
On Tue, Oct 18, 2022 at 4:25 PM liuhongt wrote: > > Fix unexpected non-canon form from gimple vector selector. > > Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > Ok for trunk? > > gcc/ChangeLog: > > PR target/107271 > * config/i386/i386-expand.cc

Re: [COMMITTED 4/4] PR tree-optimization/102540 - propagate partial equivs in the cache.

2022-10-17 Thread H.J. Lu via Gcc-patches
On Thu, Oct 13, 2022 at 8:32 AM Andrew MacLeod via Gcc-patches wrote: > > Rangers on entry cache propagation already evaluates equivalences when > calculating values. This patch also allows it to work with partial > equivalences, and if the bit sizes are compatible, make use of those > ranges as

Re: [PATCH] Add new target hook: simplify_modecc_const.

2022-10-14 Thread H.J. Lu via Gcc-patches
On Fri, Oct 14, 2022 at 1:32 PM Jeff Law via Gcc-patches wrote: > > > On 10/10/22 09:50, H.J. Lu via Gcc-patches wrote: > > On Thu, Jul 28, 2022 at 5:40 AM Richard Sandiford via Gcc-patches > > wrote: > >> Seems this thread has become a bit heated, so I'll tr

Re: [PATCH][ICE] Fix for PR107193.

2022-10-10 Thread H.J. Lu via Gcc-patches
On Mon, Oct 10, 2022 at 5:37 PM Eugene Rozenfeld wrote: > > The bug was introduced in f30e9fd33e56a5a721346ea6140722e1b193db42. > A variable (cur_locus_e) was incorrectly declared inside a loop. > I also moved two other declarations (last and locus) down to make > the code more clear. > > Tested

Re: [PATCH] Add new target hook: simplify_modecc_const.

2022-10-10 Thread H.J. Lu via Gcc-patches
On Thu, Jul 28, 2022 at 5:40 AM Richard Sandiford via Gcc-patches wrote: > > Seems this thread has become a bit heated, so I'll try to proceed > with caution :-) > > In the below, I'll use "X-mode const_int" to mean "a const_int that > is known from context to represent an X-mode value". Of

PING^1: [PATCH] x86: Check corrupted return address when unwinding stack

2022-10-04 Thread H.J. Lu via Gcc-patches
On Wed, Sep 21, 2022 at 1:42 PM H.J. Lu wrote: > > If shadow stack is enabled, when unwinding stack, we count how many stack > frames we pop to reach the landing pad and adjust shadow stack by the same > amount. When counting the stack frame, we compare the return address on > normal stack

Re: [committed] Minor cleanup/prep in DOM

2022-09-30 Thread H.J. Lu via Gcc-patches
On Fri, Sep 30, 2022 at 4:06 PM Jeff Law wrote: > > > It's a bit weird that free_dom_edge_info leaves a dangling pointer in > e->aux. Not sure what I was thinking. > > > There's two callers. One wipes e->aux immediately after the call, the > other attaches a newly created object immediately

Re: [PATCH] Document -fexcess-precision=16 in tm.texi

2022-09-30 Thread H.J. Lu via Gcc-patches
On Fri, Sep 30, 2022 at 3:25 PM Palmer Dabbelt wrote: > > On Sat, 24 Sep 2022 19:13:36 PDT (-0700), san...@codesourcery.com wrote: > > On 9/18/22 02:47, Palmer Dabbelt wrote: > >> On Fri, 09 Sep 2022 02:46:40 PDT (-0700), Palmer Dabbelt wrote: > >>> I just happened to stuble on this one while

[PATCH] i386: Mark XMM4-XMM6 as clobbered by encodekey128/encodekey256

2022-09-27 Thread H.J. Lu via Gcc-patches
encodekey128 and encodekey256 operations clear XMM4-XMM6. But it is documented that XMM4-XMM6 are reserved for future usages and software should not rely upon them being zeroed. Change encodekey128 and encodekey256 to clobber XMM4-XMM6. gcc/ PR target/107061 *

Re: [RFC] postreload cse'ing vector constants

2022-09-27 Thread H.J. Lu via Gcc-patches
On Tue, Sep 27, 2022 at 10:46 AM Robin Dapp via Gcc-patches wrote: > > > I did bootstrapping and ran the testsuite on x86(-64), aarch64, Power9 > > and s390. Everything looks good except two additional fails on x86 > > where code actually looks worse. > > > >

Re: [PATCH] Ignore debug insns with CONCAT and CONCATN for insn scheduling

2022-09-26 Thread H.J. Lu via Gcc-patches
On Sat, Sep 24, 2022 at 1:37 PM Jeff Law wrote: > > > On 9/21/22 16:11, H.J. Lu wrote: > > On Wed, Sep 7, 2022 at 10:03 AM Jeff Law via Gcc-patches > > wrote: > >> > >> > >> On 9/2/2022 8:36 AM, H.J. Lu via Gcc-patches wrote: > &g

Re: [PATCH] Ignore debug insns with CONCAT and CONCATN for insn scheduling

2022-09-21 Thread H.J. Lu via Gcc-patches
On Wed, Sep 7, 2022 at 10:03 AM Jeff Law via Gcc-patches wrote: > > > > On 9/2/2022 8:36 AM, H.J. Lu via Gcc-patches wrote: > > CONCAT and CONCATN never appear in the insn chain. They are only used > > in debug insn. Ignore debug insns with CONCAT and CONCATN for insn

[PATCH] x86: Check corrupted return address when unwinding stack

2022-09-21 Thread H.J. Lu via Gcc-patches
If shadow stack is enabled, when unwinding stack, we count how many stack frames we pop to reach the landing pad and adjust shadow stack by the same amount. When counting the stack frame, we compare the return address on normal stack against the return address on shadow stack. If they don't

[PATCH] Ignore debug insns with CONCAT and CONCATN for insn scheduling

2022-09-02 Thread H.J. Lu via Gcc-patches
CONCAT and CONCATN never appear in the insn chain. They are only used in debug insn. Ignore debug insns with CONCAT and CONCATN for insn scheduling to avoid different insn orders with and without debug insn. gcc/ PR rtl-optimization/106746 * sched-deps.cc (sched_analyze_2):

Re: [PATCH] i386: Fix conversion of move to/from AX_REG into xchg [PR106707]

2022-09-01 Thread H.J. Lu via Gcc-patches
On Thu, Sep 1, 2022 at 11:23 AM Uros Bizjak via Gcc-patches wrote: > > The conversion of a move pattern where both operands are AX_REG > should be prevented. > > 2022-09-01 Uroš Bizjak > > gcc/ChangeLog: > > PR target/106707 > * config/i386/i386.md (moves to/from AX_REG into xchg

[PATCH] x86: Handle V16BF in ix86_avx256_split_vector_move_misalign

2022-08-26 Thread H.J. Lu via Gcc-patches
Handle E_V16BFmode in ix86_avx256_split_vector_move_misalign and add V16BF to V_256H iterator. gcc/ PR target/106748 * config/i386/i386-expand.cc (ix86_avx256_split_vector_move_misalign): Handle E_V16BFmode. * config/i386/sse.md (V_256H): Add V16BF.

Re: [PATCH] x86: Cast stride to __PTRDIFF_TYPE__ in AMX intrinsics

2022-08-26 Thread H.J. Lu via Gcc-patches
On Mon, Aug 22, 2022 at 7:05 PM Hongtao Liu wrote: > > On Tue, Aug 23, 2022 at 1:02 AM H.J. Lu wrote: > > > > On 64-bit Windows, long is 32 bits and can't be used as stride in memory > > operand when base is a pointer which is 64 bits. Cast stride to > > __PTRDIFF_TYPE__, instead of long. > Ok.

[PATCH] x86: Replace vmovdqu with movdqu in BF16 XMM ABI tests

2022-08-23 Thread H.J. Lu via Gcc-patches
I am checking in this as an obvious fix. H.J. --- Since XMM BF16 tests only require SSE2, replace vmovdqu with movdqu in BF16 XMM ABI tests to support SSE2 machines without AVX. Tested on x86-64 machines with and without AVX. * gcc.target/x86_64/abi/bf16/asm-support.S: Replace vmovdqu

[PATCH] x86: Cast stride to __PTRDIFF_TYPE__ in AMX intrinsics

2022-08-22 Thread H.J. Lu via Gcc-patches
On 64-bit Windows, long is 32 bits and can't be used as stride in memory operand when base is a pointer which is 64 bits. Cast stride to __PTRDIFF_TYPE__, instead of long. PR target/106714 * config/i386/amxtileintrin.h (_tile_loadd_internal): Cast to __PTRDIFF_TYPE__.

Re: [PATCH] Add ABI test for __bf16 type

2022-08-19 Thread H.J. Lu via Gcc-patches
On Thu, Aug 18, 2022 at 5:56 PM Hongtao Liu via Gcc-patches wrote: > > On Thu, Aug 18, 2022 at 3:36 PM Haochen Jiang via Gcc-patches > wrote: > > > > Hi all, > > > > This patch aims to add bf16 abi test after the whole __bf16 type is added. > > > > Regtested on x86_64-pc-linux-gnu. Ok for trunk?

Re: [PATCH] stack-protector: Check stack canary for noreturn function

2022-08-17 Thread H.J. Lu via Gcc-patches
On Wed, Aug 3, 2022 at 10:27 AM H.J. Lu wrote: > > On Tue, Aug 2, 2022 at 4:34 PM Jeff Law wrote: > > > > > > > > On 8/2/2022 11:43 AM, H.J. Lu wrote: > > > On Sat, Jul 30, 2022 at 1:30 PM Jeff Law via Gcc-patches > > > wrote: > > >>

[PATCH v2] stack-protector: Check stack canary before throwing exception

2022-08-17 Thread H.J. Lu via Gcc-patches
Check stack canary before throwing exception to avoid stack corruption. gcc/ PR middle-end/58245 * calls.cc: Include "tree-eh.h". (expand_call): Check stack canary before throwing exception. gcc/testsuite/ PR middle-end/58245 *

Re: [PATCH 2/2]middle-end: Support recognition of three-way max/min.

2022-08-03 Thread H.J. Lu via Gcc-patches
On Wed, Aug 3, 2022 at 1:26 AM Richard Biener via Gcc-patches wrote: > > On Wed, 3 Aug 2022, Tamar Christina wrote: > > > > > > -Original Message- > > > From: Richard Biener > > > Sent: Tuesday, August 2, 2022 10:11 AM > > > To: Tamar Christina > > > Cc: Richard Biener ;

Re: [PATCH] stack-protector: Check stack canary for noreturn function

2022-08-03 Thread H.J. Lu via Gcc-patches
On Tue, Aug 2, 2022 at 4:34 PM Jeff Law wrote: > > > > On 8/2/2022 11:43 AM, H.J. Lu wrote: > > On Sat, Jul 30, 2022 at 1:30 PM Jeff Law via Gcc-patches > > wrote: > >> > >> > >> On 7/14/2022 3:55 PM, H.J. Lu via Gcc-patches wrote: > >&

Re: [PATCH] stack-protector: Check stack canary for noreturn function

2022-08-02 Thread H.J. Lu via Gcc-patches
On Sat, Jul 30, 2022 at 1:30 PM Jeff Law via Gcc-patches wrote: > > > > On 7/14/2022 3:55 PM, H.J. Lu via Gcc-patches wrote: > > Check stack canary for noreturn function to catch stack corruption > > before calling noreturn function. For C++, check stack canary whe

Re: [PATCH] [PR83782] i386 PIE: avoid @GOTOFF for ifuncs and their aliases

2022-08-01 Thread H.J. Lu via Gcc-patches
On Thu, Jul 28, 2022 at 9:31 AM H.J. Lu wrote: > > On Thu, Jul 28, 2022 at 1:26 AM Alexandre Oliva wrote: > > > > On Jul 27, 2022, "H.J. Lu" wrote: > > > > > On Tue, Jul 26, 2022 at 10:14 PM Alexandre Oliva > > > wrote: > > > > >> The use of @GOTOFF for locally-bound but externally-visible

Re: [x86_64 PATCH] PR target/106450: Tweak timode_remove_non_convertible_regs.

2022-07-28 Thread H.J. Lu via Gcc-patches
On Thu, Jul 28, 2022 at 9:43 AM Roger Sayle wrote: > > > This patch resolves PR target/106450, some more fall-out from more > aggressive TImode scalar-to-vector (STV) optimizations. I continue > to be caught out by how far TImode STV has diverged from DImode/SImode > STV, and therefore requires

Re: [PATCH] [PR83782] i386 PIE: avoid @GOTOFF for ifuncs and their aliases

2022-07-28 Thread H.J. Lu via Gcc-patches
On Thu, Jul 28, 2022 at 1:26 AM Alexandre Oliva wrote: > > On Jul 27, 2022, "H.J. Lu" wrote: > > > On Tue, Jul 26, 2022 at 10:14 PM Alexandre Oliva wrote: > > >> The use of @GOTOFF for locally-bound but externally-visible symbols > >> (e.g. protected visibility) also breaks pointer identity if

PING [PATCH] x86: Add ix86_ifunc_ref_local_ok

2022-07-27 Thread H.J. Lu via Gcc-patches
On Thu, Jul 21, 2022 at 11:53 AM H.J. Lu wrote: > > We can't always use the PLT entry as the function address for local IFUNC > functions. When the PIC register is needed for PLT call, indirect call > via the PLT entry will fail since the PIC register may not be set up > properly for indirect

Re: [PATCH] [PR83782] i386 PIE: avoid @GOTOFF for ifuncs and their aliases

2022-07-27 Thread H.J. Lu via Gcc-patches
On Tue, Jul 26, 2022 at 10:14 PM Alexandre Oliva wrote: > > > g++.dg/ext/attr-ifunc-3.C and gcc.target/i386/mvc10.c, not changed, > have made it clear that there were problems in the optimizations to > use @GOTOFF to refer to locally-bound ifuncs. GNU ld as recently as > May 2018 would reject

[GCC 12] [PATCH] x86: Support 2/4/8 byte constant vector stores

2022-07-27 Thread H.J. Lu via Gcc-patches
On Fri, Jul 1, 2022 at 8:31 AM Uros Bizjak wrote: > > On Thu, Jun 30, 2022 at 4:50 PM H.J. Lu wrote: > > > > 1. Add a predicate for constant vectors which can be converted to integer > > constants suitable for constant integer stores. For a 8-byte constant > > vector, the converted 64-bit

Re: [PATCH] tree-optimization/106379 - add missing ~(a ^ b) folding for _Bool

2022-07-25 Thread H.J. Lu via Gcc-patches
On Fri, Jul 22, 2022 at 11:10 PM Richard Biener via Gcc-patches wrote: > > > > > Am 22.07.2022 um 22:17 schrieb H.J. Lu via Gcc-patches > > : > > > > On Thu, Jul 21, 2022 at 4:24 AM Richard Biener via Gcc-patches > > wrote: > >> > >

Re: [PATCH] tree-optimization/106379 - add missing ~(a ^ b) folding for _Bool

2022-07-22 Thread H.J. Lu via Gcc-patches
On Thu, Jul 21, 2022 at 4:24 AM Richard Biener via Gcc-patches wrote: > > The following makes sure to fold ~(a ^ b) to a == b for truth > values (but not vectors, we'd have to check for vector support of > equality). That turns the PR106379 testcase into a ranger one. > > Note that while we

[PATCH] x86: Add ix86_ifunc_ref_local_ok

2022-07-21 Thread H.J. Lu via Gcc-patches
We can't always use the PLT entry as the function address for local IFUNC functions. When the PIC register is needed for PLT call, indirect call via the PLT entry will fail since the PIC register may not be set up properly for indirect call. Add ix86_ifunc_ref_local_ok to return false when the

[PATCH] stack-protector: Check stack canary for noreturn function

2022-07-14 Thread H.J. Lu via Gcc-patches
Check stack canary for noreturn function to catch stack corruption before calling noreturn function. For C++, check stack canary when throwing exception or resuming stack unwind to avoid corrupted stack. gcc/ PR middle-end/58245 * calls.cc (expand_call): Check stack canary for

Re: [PATCH v3] Simplify memchr with small constant strings

2022-07-14 Thread H.J. Lu via Gcc-patches
On Wed, Jul 13, 2022 at 11:42 PM Richard Biener wrote: > > On Wed, Jul 13, 2022 at 6:50 PM H.J. Lu wrote: > > > > When memchr is applied on a constant string of no more than the bytes of > > a word, simplify memchr by checking each byte in the constant string. > > > > int f (int a) > > { > >

[PATCH] x86: Disable sibcall if indirect_return attribute doesn't match

2022-07-14 Thread H.J. Lu via Gcc-patches
When shadow stack is enabled, function with indirect_return attribute may return via indirect jump. In this case, we need to disable sibcall if caller doesn't have indirect_return attribute and indirect branch tracking is enabled since compiler won't generate ENDBR when calling the caller. gcc/

Re: [PATCH v2] Simplify memchr with small constant strings

2022-07-13 Thread H.J. Lu via Gcc-patches
On Wed, Jul 13, 2022 at 5:35 AM Richard Biener wrote: > > On Tue, Jul 12, 2022 at 6:59 PM H.J. Lu wrote: > > > > On Fri, Jul 8, 2022 at 5:54 AM Richard Biener > > wrote: > > > > > > On Thu, Jul 7, 2022 at 6:45 PM H.J. Lu wrote: > > > > > > > > When memchr is applied on a constant string of no

[PATCH v3] Simplify memchr with small constant strings

2022-07-13 Thread H.J. Lu via Gcc-patches
When memchr is applied on a constant string of no more than the bytes of a word, simplify memchr by checking each byte in the constant string. int f (int a) { return __builtin_memchr ("AE", a, 2) != 0; } is simplified to int f (int a) { return ((char) a == 'A' || (char) a == 'E') != 0; }

Re: [PATCH v2] Simplify memchr with small constant strings

2022-07-12 Thread H.J. Lu via Gcc-patches
On Fri, Jul 8, 2022 at 5:54 AM Richard Biener wrote: > > On Thu, Jul 7, 2022 at 6:45 PM H.J. Lu wrote: > > > > When memchr is applied on a constant string of no more than the bytes of > > a word, simplify memchr by checking each byte in the constant string. > > > > int f (int a) > > { > >

Re: [x86_64 PATCH] Improved Scalar-To-Vector (STV) support for TImode to V1TImode.

2022-07-10 Thread H.J. Lu via Gcc-patches
On Sun, Jul 10, 2022 at 2:38 PM Roger Sayle wrote: > > > Hi HJ, > > I believe this should now be handled by the post-reload (CSE) pass. > Consider the simple test case: > > __int128 a, b, c; > void foo() > { > a = 0; > b = 0; > c = 0; > } > > Without any STV, i.e. -O2 -msse4 -mno-stv, GCC

Re: [x86_64 PATCH] Improved Scalar-To-Vector (STV) support for TImode to V1TImode.

2022-07-10 Thread H.J. Lu via Gcc-patches
On Sun, Jul 10, 2022 at 11:36 AM Roger Sayle wrote: > > > Hi Uros, > Yes, I agree. I think it makes sense to have a single STV pass (after > combine and before reload). Let's hear what HJ thinks, but I'm > happy to investigate a follow-up patch that unifies the STV passes. > But it'll be easier

Re: [PATCH] Inline memchr with a small constant string

2022-07-07 Thread H.J. Lu via Gcc-patches
; > > > > > > On Tue, Jun 21, 2022 at 11:03 PM H.J. Lu via Gcc-patches > > > > wrote: > > > > > > > > > > When memchr is applied on a constant string of no more than the bytes > > > > > of > > > > > a word, inli

[PATCH v2] Simplify memchr with small constant strings

2022-07-07 Thread H.J. Lu via Gcc-patches
When memchr is applied on a constant string of no more than the bytes of a word, simplify memchr by checking each byte in the constant string. int f (int a) { return __builtin_memchr ("AE", a, 2) != 0; } is simplified to int f (int a) { return ((char) a == 'A' || (char) a == 'E') != 0; }

Re: [PATCH v2] Enable __memcmpeq after seeing __memcmpeq prototype

2022-07-05 Thread H.J. Lu via Gcc-patches
On Fri, Jul 1, 2022 at 12:51 AM Richard Biener wrote: > > On Mon, Jun 20, 2022 at 5:44 PM H.J. Lu wrote: > > > > extern int __memcmpeq (const void *, const void *, size_t); > > > > was was added to GLIBC 2.35. Expand BUILT_IN_MEMCMP_EQ to __memcmpeq > > after seeing __memcmpeq prototype > > Can

[PATCH v3] Enable __memcmpeq after seeing __memcmpeq prototype

2022-07-05 Thread H.J. Lu via Gcc-patches
extern int __memcmpeq (const void *, const void *, size_t); was was added to GLIBC 2.35. Expand BUILT_IN_MEMCMP_EQ to __memcmpeq after seeing __memcmpeq prototype gcc/ * builtins.cc (expand_builtin): Issue an error for BUILT_IN___MEMCMPEQ if there is no __memcmpeq prototype.

[PATCH] x86: Support 2/4/8 byte constant vector stores

2022-06-30 Thread H.J. Lu via Gcc-patches
1. Add a predicate for constant vectors which can be converted to integer constants suitable for constant integer stores. For a 8-byte constant vector, the converted 64-bit integer must be valid for store with 64-bit immediate, which is a 64-bit integer sign-extended from a 32-bit integer. 2. Add

Re: PING^1 [PATCH] x86: Skip ENDBR when emitting direct call/jmp to local function

2022-06-27 Thread H.J. Lu via Gcc-patches
On Sun, Jun 26, 2022 at 10:50 PM Hongtao Liu wrote: > > On Tue, Jun 21, 2022 at 3:50 AM Uros Bizjak via Gcc-patches > wrote: > > > > On Mon, Jun 20, 2022 at 8:14 PM H.J. Lu wrote: > > > > > > On Tue, May 10, 2022 at 9:25 AM H.J. Lu wrote: > > > > > > > > Mark a function with

Re: [PATCH] Inline memchr with a small constant string

2022-06-23 Thread H.J. Lu via Gcc-patches
On Wed, Jun 22, 2022 at 11:03 PM Richard Biener wrote: > > On Wed, Jun 22, 2022 at 7:13 PM H.J. Lu wrote: > > > > On Wed, Jun 22, 2022 at 4:39 AM Richard Biener > > wrote: > > > > > > On Tue, Jun 21, 2022 at 11:03 PM H.J. Lu via Gcc-patches > >

Re: [PATCH] Inline memchr with a small constant string

2022-06-22 Thread H.J. Lu via Gcc-patches
On Wed, Jun 22, 2022 at 4:39 AM Richard Biener wrote: > > On Tue, Jun 21, 2022 at 11:03 PM H.J. Lu via Gcc-patches > wrote: > > > > When memchr is applied on a constant string of no more than the bytes of > > a word, inline memchr by checking each byte in the constant

[PATCH] Inline memchr with a small constant string

2022-06-21 Thread H.J. Lu via Gcc-patches
When memchr is applied on a constant string of no more than the bytes of a word, inline memchr by checking each byte in the constant string. int f (int a) { return __builtin_memchr ("eE", a, 2) != 0; } is simplified to int f (int a) { return (char) a == 'e' || (char) a == 'E'; } gcc/

Re: PING^1 [PATCH] i386: Disallow sibcall when calling ifunc functions with PIC register

2022-06-21 Thread H.J. Lu via Gcc-patches
On Mon, Jun 20, 2022 at 7:51 AM Uros Bizjak wrote: > > On Mon, Jun 20, 2022 at 4:03 PM H.J. Lu wrote: > > > > On Tue, Jun 14, 2022 at 12:25 PM H.J. Lu wrote: > > > > > > Disallow siball when calling ifunc functions with PIC register so that > > > PIC register can be restored. > > > > > > gcc/ >

PING^1 [PATCH] x86: Skip ENDBR when emitting direct call/jmp to local function

2022-06-20 Thread H.J. Lu via Gcc-patches
On Tue, May 10, 2022 at 9:25 AM H.J. Lu wrote: > > Mark a function with SYMBOL_FLAG_FUNCTION_ENDBR when inserting ENDBR at > function entry. Skip the 4-byte ENDBR when emitting a direct call/jmp > to a local function with ENDBR at function entry. > > This has been tested on Linux kernel. > >

Re: [PATCH v1] tree-optimization/95821 - Convert strlen + strchr to memchr

2022-06-20 Thread H.J. Lu via Gcc-patches
On Mon, Jun 20, 2022 at 10:29 AM Jakub Jelinek wrote: > > On Mon, Jun 20, 2022 at 09:35:36AM -0700, Noah Goldstein via Gcc-patches > wrote: > > This patch allows for strchr(x, c) to the replace with memchr(x, c, > > strlen(x) + 1) if strlen(x) has already been computed earlier in the > > tree. >

Re: [PATCH] Add -fextra-libc-function=memcmpeq for __memcmpeq

2022-06-20 Thread H.J. Lu via Gcc-patches
On Mon, Jun 20, 2022 at 2:39 AM Richard Biener wrote: > > On Thu, Jun 16, 2022 at 1:38 AM Fangrui Song wrote: > > > > On Wed, Jun 15, 2022 at 2:44 PM H.J. Lu via Gcc-patches > > wrote: > > > > > > On Mon, Jun 13, 2022 at 9:01 AM Richard Biener > >

[PATCH v2] Enable __memcmpeq after seeing __memcmpeq prototype

2022-06-20 Thread H.J. Lu via Gcc-patches
extern int __memcmpeq (const void *, const void *, size_t); was was added to GLIBC 2.35. Expand BUILT_IN_MEMCMP_EQ to __memcmpeq after seeing __memcmpeq prototype gcc/ * builtins.cc (have_memcmpeq_prototype): New. (expand_builtin): Issue an error for BUILT_IN___MEMCMPEQ if

PING^1 [PATCH] i386: Disallow sibcall when calling ifunc functions with PIC register

2022-06-20 Thread H.J. Lu via Gcc-patches
On Tue, Jun 14, 2022 at 12:25 PM H.J. Lu wrote: > > Disallow siball when calling ifunc functions with PIC register so that > PIC register can be restored. > > gcc/ > > PR target/105960 > * config/i386/i386.cc (ix86_function_ok_for_sibcall): Return > false if PIC register

Re: [PATCH] Add -fextra-libc-function=memcmpeq for __memcmpeq

2022-06-15 Thread H.J. Lu via Gcc-patches
On Mon, Jun 13, 2022 at 9:01 AM Richard Biener wrote: > > > > > Am 13.06.2022 um 16:36 schrieb H.J. Lu : > > > > On Mon, Jun 13, 2022 at 3:11 AM Richard Biener > > wrote: > >> > >>> On Tue, Jun 7, 2022 at 9:02 PM H.J. Lu via Gcc-patch

[PATCH] i386: Disallow sibcall when calling ifunc functions with PIC register

2022-06-14 Thread H.J. Lu via Gcc-patches
Disallow siball when calling ifunc functions with PIC register so that PIC register can be restored. gcc/ PR target/105960 * config/i386/i386.cc (ix86_function_ok_for_sibcall): Return false if PIC register is used when calling ifunc functions. gcc/testsuite/ PR

Re: [PATCH] Add -fextra-libc-function=memcmpeq for __memcmpeq

2022-06-13 Thread H.J. Lu via Gcc-patches
On Mon, Jun 13, 2022 at 3:11 AM Richard Biener wrote: > > On Tue, Jun 7, 2022 at 9:02 PM H.J. Lu via Gcc-patches > wrote: > > > > Add -fextra-libc-function=memcmpeq to map > > > > extern int __memcmpeq (const void *, const void *, size_t); >

[PATCH] x86: Require AVX for F16C and VAES

2022-06-10 Thread H.J. Lu via Gcc-patches
Since F16C and VAES are only usable with AVX, require AVX for F16C and VAES. OK for master and release branches? Thanks. H.J. --- libgcc/105920 * common/config/i386/cpuinfo.h (get_available_features): Require AVX for F16C and VAES. --- gcc/common/config/i386/cpuinfo.h |

Re: [PATCH] Add optional __Bfloat16 support

2022-06-10 Thread H.J. Lu via Gcc-patches
On Fri, Jun 10, 2022 at 7:44 AM H.J. Lu wrote: > > On Fri, Jun 10, 2022 at 2:38 AM Florian Weimer wrote: > > > > * liuhongt via Libc-alpha: > > > > > +\subsubsection{Special Types} > > > + > > > +The \code{__Bfloat16} type uses a 8-bit exponent and 7-bit mantissa. > > > +It is used for

Re: [PATCH] Add optional __Bfloat16 support

2022-06-10 Thread H.J. Lu via Gcc-patches
On Fri, Jun 10, 2022 at 2:38 AM Florian Weimer wrote: > > * liuhongt via Libc-alpha: > > > +\subsubsection{Special Types} > > + > > +The \code{__Bfloat16} type uses a 8-bit exponent and 7-bit mantissa. > > +It is used for \code{BF16} related intrinsics, it cannot be Please mention that this is

[PATCH] Add -fextra-libc-function=memcmpeq for __memcmpeq

2022-06-07 Thread H.J. Lu via Gcc-patches
Add -fextra-libc-function=memcmpeq to map extern int __memcmpeq (const void *, const void *, size_t); which was added to GLIBC 2.35, to __builtin_memcmp_eq. gcc/ * builtins.cc: Include "opts.h". (expand_builtin): Generate BUILT_IN_MEMCMP_EQ if __memcmpeq is available.

Re: [PATCH] x86: harmonize __builtin_ia32_psadbw*() types

2022-06-06 Thread H.J. Lu via Gcc-patches
On Sun, Jun 5, 2022 at 7:27 PM Hongtao Liu via Gcc-patches wrote: > > On Mon, Jun 6, 2022 at 3:17 AM Uros Bizjak via Gcc-patches > wrote: > > > > On Thu, Jun 2, 2022 at 5:04 PM Jan Beulich wrote: > > > > > > The 64-bit, 128-bit, and 512-bit variants have VDI return type, in > > > line with

Re: [PATCH v3] RISC-V: Implement C[LT]Z_DEFINED_VALUE_AT_ZERO

2022-06-03 Thread H.J. Lu via Gcc-patches
On Fri, May 13, 2022 at 1:17 PM Philipp Tomsich wrote: > > The Zbb support has introduced ctz and clz to the backend, but some > transformations in GCC need to know what the value of c[lt]z at zero > is. This affects how the optab is generated and may suppress use of > CLZ/CTZ in tree passes. > >

Re: [PATCH v4] DSE: Use the constant store source if possible

2022-06-01 Thread H.J. Lu via Gcc-patches
On Wed, Jun 1, 2022 at 12:20 AM Richard Sandiford wrote: > > "H.J. Lu" writes: > > On Mon, May 30, 2022 at 09:35:43AM +0100, Richard Sandiford wrote: > >> "H.J. Lu" writes: > >> > --- > >> > RTL DSE tracks redundant constant stores within a basic block. When RTL > >> > loop invariant motion

Re: [PATCH] Update {skylake,icelake,alderlake}_cost to add a bit preference to vector store.

2022-06-01 Thread H.J. Lu via Gcc-patches
On Tue, May 31, 2022 at 10:06 PM Cui,Lili wrote: > > This patch is to update {skylake,icelake,alderlake}_cost to add a bit > preference to vector store. > Since the interger vector construction cost has changed, we need to adjust > the load and store costs for intel processers. > > With the

  1   2   3   4   5   6   7   8   9   10   >