https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125100
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by H.J. Lu <[email protected]>: https://gcc.gnu.org/g:12e4a2acda8da558010c9962f96b3167aee21072 commit r17-397-g12e4a2acda8da558010c9962f96b3167aee21072 Author: H.J. Lu <[email protected]> Date: Thu Apr 30 09:21:27 2026 +0800 x86_cse: Add X86_CSE_CONST_VECTOR Add X86_CSE_CONST_VECTOR for native CONST_VECTOR: (insn 25 23 234 4 (set (reg:V16QI 135) (const_vector:V16QI [ (const_int -1 [0xffffffffffffffff]) repeated x16 ])) "bar-2.c":10:16 discrim 67584 2453 {movv16qi_internal} (nil)) and constant integer load: (insn 280 8 279 2 (set (subreg:HI (reg:V2QI 172) 0) (const_int -1 [0xffffffffffffffff])) -1 (nil)) ... (insn 110 39 194 9 (set (reg:V2QI 147) (reg:V2QI 172)) 2089 {*movv2qi_internal} (expr_list:REG_EQUAL (const_vector:V2QI [ (const_int -1 [0xffffffffffffffff]) repeated x2 ]) (nil))) converted from (insn 111 87 121 18 (set (reg:V2QI 147) (mem/u/c:V2QI (symbol_ref/u:DI ("*.LC0") [flags 0x2]) [0 S2 A16])) 2089 {*movv2qi_internal} (expr_list:REG_EQUAL (const_vector:V2QI [ (const_int -1 [0xffffffffffffffff]) repeated x2]) (nil))) 1. Use CONST_VECTOR in REG_EQUAL note to avoid DF chain. 2. Keep constant integer load when crossing a function call since it is faster than save and restore an integer register. 3. Convert CONST_VECTOR load no larger than integer register to constant integer load even if there is no redundant CONST_VECTOR load. Tested on Linux/x86-64. gcc/ PR target/125100 * config/i386/i386-features.cc (x86_cse_kind): Add X86_CSE_CONST_VECTOR. (redundant_pattern): Add dest_mode. (ix86_place_single_vector_set): Handle X86_CSE_CONST_VECTOR. Generate SUBREG for constant integer source. (ix86_broadcast_inner): Add an INSN argument. Use CONST_VECTOR in REG_EQUAL note. Set load kind to X86_CSE_CONST_VECTOR for native and converted CONST_VECTORs. Return CONST_VECTOR if it can be converted to constant integer load. (pass_x86_cse::candidate_vector_p): Add an INSN argument and pass the insn to ix86_broadcast_inner. (pass_x86_cse::x86_cse): Add a basic block bitmap for calls. Pass the insn to candidate_vector_p. Handle X86_CSE_CONST_VECTOR. Set dest_mode. Keep constant integer load when crossing a function call. Convert CONST_VECTOR load no larger than integer register to constant integer load even if there are no redundant CONST_VECTOR loads. gcc/testsuite/ PR target/125100 * gcc.target/i386/pr125100-1.c: New test. * gcc.target/i386/pr125100-2.c: Likewise. * gcc.target/i386/pr125100-3.c: Likewise. * gcc.target/i386/pr125100-4.c: Likewise. Signed-off-by: H.J. Lu <[email protected]>
