Commit Graph

66765 Commits

Author SHA1 Message Date
H.J. Lu c03a554103 x86: Add -mfunction-return=
Add -mfunction-return= option to convert function return to call and
return thunks.  The default is 'keep', which keeps function return
unmodified.  'thunk' converts function return to call and return thunk.
'thunk-inline' converts function return to inlined call and return thunk.
'thunk-extern' converts function return to external call and return
thunk provided in a separate object file.  You can control this behavior
for a specific function by using the function attribute function_return.

Function return thunk is the same as memory thunk for -mindirect-branch=
where the return address is at the top of the stack:

__x86_return_thunk:
	call L2
L1:
	pause
	lfence
	jmp L1
L2:
	lea 8(%rsp), %rsp|lea 4(%esp), %esp
	ret

and function return becomes

	jmp __x86_return_thunk

-mindirect-branch= tests are updated with -mfunction-return=keep to
avoid false test failures when -mfunction-return=thunk is added to
RUNTESTFLAGS for "make check".

gcc/

	Backport from mainline
	2018-01-14  H.J. Lu  <hongjiu.lu@intel.com>

	* config/i386/i386-protos.h (ix86_output_function_return): New.
	* config/i386/i386.c (ix86_set_indirect_branch_type): Also
	set function_return_type.
	(indirect_thunk_name): Add ret_p to indicate thunk for function
	return.
	(output_indirect_thunk_function): Pass false to
	indirect_thunk_name.
	(ix86_output_indirect_branch_via_reg): Likewise.
	(ix86_output_indirect_branch_via_push): Likewise.
	(output_indirect_thunk_function): Create alias for function
	return thunk if regno < 0.
	(ix86_output_function_return): New function.
	(ix86_handle_fndecl_attribute): Handle function_return.
	(ix86_attribute_table): Add function_return.
	* config/i386/i386.h (machine_function): Add
	function_return_type.
	* config/i386/i386.md (simple_return_internal): Use
	ix86_output_function_return.
	(simple_return_internal_long): Likewise.
	* config/i386/i386.opt (mfunction-return=): New option.
	(indirect_branch): Mention -mfunction-return=.
	* doc/extend.texi: Document function_return function attribute.
	* doc/invoke.texi: Document -mfunction-return= option.

gcc/testsuite/

	Backport from mainline
	2018-01-14  H.J. Lu  <hongjiu.lu@intel.com>

	* gcc.target/i386/indirect-thunk-1.c (dg-options): Add
	-mfunction-return=keep.
	* gcc.target/i386/indirect-thunk-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-5.c: Likewise.
	* gcc.target/i386/indirect-thunk-6.c: Likewise.
	* gcc.target/i386/indirect-thunk-7.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-5.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-6.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-7.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-8.c: Likewise.
	* gcc.target/i386/indirect-thunk-bnd-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-bnd-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-bnd-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-bnd-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-5.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-6.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-7.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-5.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-6.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-7.c: Likewise.
	* gcc.target/i386/ret-thunk-1.c: New test.
	* gcc.target/i386/ret-thunk-10.c: Likewise.
	* gcc.target/i386/ret-thunk-11.c: Likewise.
	* gcc.target/i386/ret-thunk-12.c: Likewise.
	* gcc.target/i386/ret-thunk-13.c: Likewise.
	* gcc.target/i386/ret-thunk-14.c: Likewise.
	* gcc.target/i386/ret-thunk-15.c: Likewise.
	* gcc.target/i386/ret-thunk-16.c: Likewise.
	* gcc.target/i386/ret-thunk-2.c: Likewise.
	* gcc.target/i386/ret-thunk-3.c: Likewise.
	* gcc.target/i386/ret-thunk-4.c: Likewise.
	* gcc.target/i386/ret-thunk-5.c: Likewise.
	* gcc.target/i386/ret-thunk-6.c: Likewise.
	* gcc.target/i386/ret-thunk-7.c: Likewise.
	* gcc.target/i386/ret-thunk-8.c: Likewise.
	* gcc.target/i386/ret-thunk-9.c: Likewise.

i386: Don't use ASM_OUTPUT_DEF for TARGET_MACHO

ASM_OUTPUT_DEF isn't defined for TARGET_MACHO.  Use ASM_OUTPUT_LABEL to
generate the __x86_return_thunk label, instead of the set directive.
Update testcase to remove the __x86_return_thunk label check.  Since
-fno-pic is ignored on Darwin, update testcases to sscan or "push"
only on Linux.

gcc/

	Backport from mainline
	2018-01-15  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/83839
	* config/i386/i386.c (output_indirect_thunk_function): Use
	ASM_OUTPUT_LABEL, instead of ASM_OUTPUT_DEF, for TARGET_MACHO
	for  __x86.return_thunk.

gcc/testsuite/

	Backport from mainline
	2018-01-15  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/83839
	* gcc.target/i386/indirect-thunk-1.c: Scan for "push" only on
	Linux.
	* gcc.target/i386/indirect-thunk-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-7.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-5.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-6.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-7.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-7.c: Likewise.
	* gcc.target/i386/indirect-thunk-register-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-register-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-register-4.c: Likewise.
	* gcc.target/i386/ret-thunk-10.c: Likewise.
	* gcc.target/i386/ret-thunk-11.c: Likewise.
	* gcc.target/i386/ret-thunk-12.c: Likewise.
	* gcc.target/i386/ret-thunk-13.c: Likewise.
	* gcc.target/i386/ret-thunk-14.c: Likewise.
	* gcc.target/i386/ret-thunk-15.c: Likewise.
	* gcc.target/i386/ret-thunk-9.c: Don't check the
	__x86_return_thunk label.
	Scan for "push" only for Linux.

From-SVN: r256734
2018-01-16 03:10:44 -08:00
H.J. Lu 0c198399c1 Update ChangeLog entries
From-SVN: r256733
2018-01-16 03:04:48 -08:00
H.J. Lu 7799a85590 x86: Add -mindirect-branch=
Add -mindirect-branch= option to convert indirect call and jump to call
and return thunks.  The default is 'keep', which keeps indirect call and
jump unmodified.  'thunk' converts indirect call and jump to call and
return thunk.  'thunk-inline' converts indirect call and jump to inlined
call and return thunk.  'thunk-extern' converts indirect call and jump to
external call and return thunk provided in a separate object file.  You
can control this behavior for a specific function by using the function
attribute indirect_branch.

2 kinds of thunks are geneated.  Memory thunk where the function address
is at the top of the stack:

__x86_indirect_thunk:
	call L2
L1:
	pause
	lfence
	jmp L1
L2:
	lea 8(%rsp), %rsp|lea 4(%esp), %esp
	ret

Indirect jmp via memory, "jmp mem", is converted to

	push memory
	jmp __x86_indirect_thunk

Indirect call via memory, "call mem", is converted to

	jmp L2
L1:
	push [mem]
	jmp __x86_indirect_thunk
L2:
	call L1

Register thunk where the function address is in a register, reg:

__x86_indirect_thunk_reg:
	call	L2
L1:
	pause
	lfence
	jmp	L1
L2:
	movq	%reg, (%rsp)|movl    %reg, (%esp)
	ret

where reg is one of (r|e)ax, (r|e)dx, (r|e)cx, (r|e)bx, (r|e)si, (r|e)di,
(r|e)bp, r8, r9, r10, r11, r12, r13, r14 and r15.

Indirect jmp via register, "jmp reg", is converted to

	jmp __x86_indirect_thunk_reg

Indirect call via register, "call reg", is converted to

	call __x86_indirect_thunk_reg

gcc/

	Backport from mainline
	* config/i386/i386-opts.h (indirect_branch): New.
	* config/i386/i386-protos.h (ix86_output_indirect_jmp): Likewise.
	* config/i386/i386.c (ix86_using_red_zone): Disallow red-zone
	with local indirect jump when converting indirect call and jump.
	(ix86_set_indirect_branch_type): New.
	(ix86_set_current_function): Call ix86_set_indirect_branch_type.
	(indirectlabelno): New.
	(indirect_thunk_needed): Likewise.
	(indirect_thunk_bnd_needed): Likewise.
	(indirect_thunks_used): Likewise.
	(indirect_thunks_bnd_used): Likewise.
	(INDIRECT_LABEL): Likewise.
	(indirect_thunk_name): Likewise.
	(output_indirect_thunk): Likewise.
	(output_indirect_thunk_function): Likewise.
	(ix86_output_indirect_branch_via_reg): Likewise.
	(ix86_output_indirect_branch_via_push): Likewise.
	(ix86_output_indirect_branch): Likewise.
	(ix86_output_indirect_jmp): Likewise.
	(ix86_code_end): Call output_indirect_thunk_function if needed.
	(ix86_output_call_insn): Call ix86_output_indirect_branch if
	needed.
	(ix86_handle_fndecl_attribute): Handle indirect_branch.
	(ix86_attribute_table): Add indirect_branch.
	* config/i386/i386.h (machine_function): Add indirect_branch_type
	and has_local_indirect_jump.
	* config/i386/i386.md (indirect_jump): Set has_local_indirect_jump
	to true.
	(tablejump): Likewise.
	(*indirect_jump): Use ix86_output_indirect_jmp.
	(*tablejump_1): Likewise.
	(simple_return_indirect_internal): Likewise.
	* config/i386/i386.opt (mindirect-branch=): New option.
	(indirect_branch): New.
	(keep): Likewise.
	(thunk): Likewise.
	(thunk-inline): Likewise.
	(thunk-extern): Likewise.
	* doc/extend.texi: Document indirect_branch function attribute.
	* doc/invoke.texi: Document -mindirect-branch= option.

gcc/testsuite/

	Backport from mainline
	* gcc.target/i386/indirect-thunk-1.c: New test.
	* gcc.target/i386/indirect-thunk-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-5.c: Likewise.
	* gcc.target/i386/indirect-thunk-6.c: Likewise.
	* gcc.target/i386/indirect-thunk-7.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-5.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-6.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-7.c: Likewise.
	* gcc.target/i386/indirect-thunk-attr-8.c: Likewise.
	* gcc.target/i386/indirect-thunk-bnd-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-bnd-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-bnd-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-bnd-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-5.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-6.c: Likewise.
	* gcc.target/i386/indirect-thunk-extern-7.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-1.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-2.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-3.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-4.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-5.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-6.c: Likewise.
	* gcc.target/i386/indirect-thunk-inline-7.c: Likewise.

From-SVN: r256732
2018-01-16 02:59:42 -08:00
Richard Biener 30bd6019be backport: re PR target/81481 (Spills %xmm to stack in glibc strspn SSE 4.2 variant)
2018-01-16  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2017-09-29  Vladimir Makarov  <vmakarov@redhat.com>

	PR target/81481
	* ira-costs.c (scan_one_insn): Don't take into account PIC equiv
	with a symbol for LRA.

	* gcc.target/i386/pr81481.c: New.

From-SVN: r256731
2018-01-16 09:51:57 +00:00
Segher Boessenkool 8cd9e9f172 backport: re PR target/83629 (ICE: in decompose_normal_address, at rtlanal.c:6329 with -O2 -fPIC -frename-registers --param=sched-autopref-queue-depth=nnn)
Backport from mainline
	2018-01-10  Segher Boessenkool  <segher@kernel.crashing.org>

	PR target/83629
	* config/rs6000/rs6000.md (load_toc_v4_PIC_2, load_toc_v4_PIC_3b,
	load_toc_v4_PIC_3c): Wrap const term in CONST RTL.

gcc/testsuite/
	Backport from mainline
	2018-01-10  Segher Boessenkool  <segher@kernel.crashing.org>

	PR target/83629
	* gcc.target/powerpc/pr83629.c: New testcase.

	2018-01-12  Segher Boessenkool  <segher@kernel.crashing.org>

	PR target/83629
	* gcc.target/powerpc/pr83629.c: Require ilp32.

From-SVN: r256711
2018-01-15 23:08:12 +01:00
H.J. Lu 1984fccf0b i386: Align stack frame if argument is passed on stack
When a function call is removed, it may become a leaf function.  But if
argument may be passed on stack, we need to align the stack frame when
there is no tail call.

Tested on Linux/i686 and Linux/x86-64.

gcc/

	Backport from mainline
	PR target/83330
	* config/i386/i386.c (ix86_function_arg_advance): Set
	outgoing_args_on_stack to true if there are outgoing arguments
	on stack.
	(ix86_function_arg): Likewise.
	(ix86_compute_frame_layout): Align stack frame if argument is
	passed on stack.
	* config/i386/i386.h (machine_function): Add
	outgoing_args_on_stack.

gcc/testsuite/

	Backport from mainline
	PR target/83330
	* gcc.target/i386/pr83330.c: New test.

From-SVN: r256703
2018-01-15 08:13:23 -08:00
H.J. Lu d031a3aaf5 i386: More use reference of struct ix86_frame to avoid copy
When there is no need to make a copy of ix86_frame, we can use reference
of struct ix86_frame to avoid copy.

	Backport from mainline
	* config/i386/i386.c (ix86_expand_prologue): Use reference of
	struct ix86_frame.
	(ix86_expand_epilogue): Likewise.

From-SVN: r256695
2018-01-15 03:33:42 -08:00
H.J. Lu ed493f2709 Move ChangeLog entries to gcc/ChangeLog
From-SVN: r256693
2018-01-15 03:32:23 -08:00
Bill Schmidt ed402c475a backport: re PR target/83677 (PPC: The xxpermr instruction is not generated correctly)
[gcc]

2018-01-14  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	Backport from mainline
	2018-01-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	PR target/83677
	* config/rs6000/altivec.md (*altivec_vpermr_<mode>_internal):
	Reverse order of second and third operands in first alternative.
	* config/rs6000/rs6000.c (rs6000_expand_vector_set): Reverse order
	of first and second elements in UNSPEC_VPERMR vector.
	(altivec_expand_vec_perm_le): Likewise.

[gcc/testsuite]

2018-01-14  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	Backport from mainline
	2018-01-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	PR target/83677
	* gcc.target/powerpc/pr83677.c: New file.

From-SVN: r256670
2018-01-14 17:47:30 +00:00
Uros Bizjak 38c84ba5d6 backport: re PR rtl-optimization/83628 (performance regression when accessing arrays on alpha)
Backport from mainline
	2018-01-12  Uros Bizjak  <ubizjak@gmail.com>

	PR target/83628
	* config/alpha/alpha.md (*saddsi_1): New insn_ans_split pattern.
	(*saddl_se_1): Ditto.
	(*ssubsi_1): Ditto.
	(*ssubl_se_1): Ditto.

	Backport from mainline
	2018-01-09  Uros Bizjak  <ubizjak@gmail.com>

	PR target/83628
	* combine.c (force_int_to_mode) <case ASHIFT>: Use mode instead of
	op_mode in the force_to_mode call.

testsuite/ChangeLog:

	Backport from mainline
	2018-01-12  Uros Bizjak  <ubizjak@gmail.com>

	PR target/83628
	* gcc.target/alpha/pr83628-3.c: New test.

From-SVN: r256665
2018-01-14 16:45:38 +01:00
Oleg Endo 22ec74897c backport: re PR target/81819 ([RX] internal compiler error: in rx_is_restricted_memory_address, at config/rx/rx.c:311)
gcc/
	Backport from mainline
	2018-01-12  Oleg Endo  <olegendo@gcc.gnu.org>

	PR target/81819
	* config/rx/rx.c (rx_is_restricted_memory_address):
	Handle SUBREG case.

From-SVN: r256579
2018-01-12 12:12:38 +00:00
Eric Botcazou 951346c205 re PR rtl-optimization/83565 (RTL combine pass yields wrong rotate result)
PR rtl-optimization/83565
	* rtlanal.c (nonzero_bits1): On WORD_REGISTER_OPERATIONS machines, do
	not extend the result to a larger mode for rotate operations.
	(num_sign_bit_copies1): Likewise.

From-SVN: r256573
2018-01-12 10:20:42 +00:00
Rainer Orth 28b93b9304 Avoid Solaris/SPARC comparison failures with Solaris as (PR bootstrap/81926)
Backport from mainline
	2018-01-04  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR bootstrap/81926
	* cgraphunit.c (symbol_table::compile): Switch to text_section
	before calling assembly_start debug hook.

From-SVN: r256562
2018-01-12 05:32:31 +00:00
Oleg Endo 05d34c633d backport: re PR target/81821 ([RX] xchg_mem<mode> uses wrong memory operand size)
gcc/
	Backport from mainline
	2018-01-11  Oleg Endo  <olegendo@gcc.gnu.org>

	PR target/81821
	* config/rx/rx.md (BW): New mode attribute.
	(sync_lock_test_and_setsi): Add mode suffix to insn output.

From-SVN: r256538
2018-01-11 15:18:38 +00:00
Richard Biener d8d1029d8e backport: re PR c++/83713 (ICE in do_narrow at gcc/convert.c:474)
2018-01-09  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2018-01-08  Richard Biener  <rguenther@suse.de>

	PR middle-end/83713
	* convert.c (do_narrow): Properly guard TYPE_OVERFLOW_WRAPS checks.

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

From-SVN: r256371
2018-01-09 08:53:14 +00:00
Jim Wilson 603ceb882d RISC-V: Fix -msave-restore bug with sibcalls.
2018-01-08  Monk Chiang  <sh.chiang04@gmail.com>
		    Kito Cheng  <kito.cheng@gmail.com>
	gcc/
	* config/riscv/riscv.c (machine_function::is_leaf): Remove field.
	(riscv_leaf_function_p): Delete.
	(riscv_function_ok_for_sibcall): Return false when TARGET_SAVE_RESTORE.

	2018-01-08  Chih-Mao Chen <pkmx.tw@gmail.com>
		    Monk Chiang  <sh.chiang04@gmail.com>
	gcc/testsuite/
	* gcc.target/riscv/save-restore-1.c: New.

	2017-11-29  Jim Wilson  <jimw@sifive.com>
	gcc/testsuite/
	* gcc.target/riscv/riscv.exp: New.

From-SVN: r256363
2018-01-08 17:01:45 -08:00
Kyrylo Tkachov 9192145f0b [arm] PR target/82975: Guard against reg_renumber being NULL in arm.h
Backport from mainline
	2017-12-20  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

	PR target/82975
	* config/arm/arm.h (TEST_REGNO): Adjust comment as expected in r255830.

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

From-SVN: r256350
2018-01-08 18:42:50 +00:00
Sebastian Huber 2fc75a03b0 RTEMS/EPIPHANY: Add RTEMS support
gcc/
	* config.gcc (epiphany-*-elf*): Add (epiphany-*-rtems*) configuration.
	* config/epiphany/rtems.h: New file.

libgcc/
	* config.host (epiphany-*-elf*): Add (epiphany-*-rtems*)
	configuration.

From-SVN: r256342
2018-01-08 13:39:11 +00:00
Uros Bizjak 71cacd0b5c alpha.md (*sadd<modesuffix>): Use ASHIFT instead of MULT rtx.
* config/alpha/alpha.md (*sadd<modesuffix>): Use ASHIFT
	instead of MULT rtx.  Update all corresponding splitters.
	(*saddl_se): Ditto.
	(*ssub<modesuffix>): Ditto.
	(*ssubl_se): Ditto.
	(*cmp_sadd_di): Update split patterns.
	(*cmp_sadd_si): Ditto.
	(*cmp_sadd_sidi): Ditto.
	(*cmp_ssub_di): Ditto.
	(*cmp_ssub_si): Ditto.
	(*cmp_ssub_sidi): Ditto.
	* config/alpha/predicates.md (const23_operand): New predicate.
	* config/alpha/alpha.c (alpha_rtx_costs) [PLUS, MINUS]:
	Look for ASHIFT, not MULT inner operand.
	(alpha_split_conditional_move): Update for *sadd<modesuffix> change.

testsuite/ChangeLog:

	* gcc.target/alpha/pr83628-1.c: New test.
	* gcc.target/alpha/pr83628-2.c: Ditto.

From-SVN: r256324
2018-01-07 20:14:55 +01:00
Andrew Waterman 1b4f0bcf4b RISC-V: Fix for icache flush issue on multicore processors.
gcc/
	* config/riscv/linux.h (ICACHE_FLUSH_FUNC): New.
	* config/riscv/riscv.md (clear_cache): Use it.

From-SVN: r256110
2018-01-02 12:57:54 -08:00
Jakub Jelinek 528dc0195d re PR rtl-optimization/83608 (ICE in convert_move, at expr.c:229 in GIMPLE store merging pass)
PR middle-end/83608
	* expr.c (store_expr_with_bounds): Use simplify_gen_subreg instead of
	convert_modes if target mode has the right side, but different mode
	class.

	* g++.dg/opt/pr83608.C: New test.

From-SVN: r256063
2018-01-01 12:30:28 +01:00
Jakub Jelinek 63563fe69e re PR tree-optimization/83609 (ICE in read_complex_part at gcc/expr.c:3202)
PR middle-end/83609
	* expr.c (expand_assignment): Fix up a typo in simplify_gen_subreg
	last argument when extracting from CONCAT.  If either from_real or
	from_imag is NULL, use expansion through memory.  If result is not
	a CONCAT and simplify_gen_subreg fails, try to simplify_gen_subreg
	the parts directly to inner mode, if even that fails, use expansion
	through memory.

	* gcc.dg/pr83609.c: New test.
	* g++.dg/opt/pr83609.C: New test.

From-SVN: r256062
2018-01-01 12:28:57 +01:00
Jakub Jelinek f0b9bc3434 re PR middle-end/83623 (ICE: in convert_move, at expr.c:248 with -march=knl and 16bit vector bswap/rotate)
PR middle-end/83623
	* expmed.c (expand_shift_1): For 2-byte rotates by BITS_PER_UNIT,
	check for bswap in mode rather than HImode and use that in expand_unop
	too.

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

From-SVN: r256061
2018-01-01 12:27:17 +01:00
Jakub Jelinek 11942b1776 re PR c++/83553 (compiler removes body of the for-loop, although there is a case label inside)
PR c++/83553
	* fold-const.c (struct contains_label_data): New type.
	(contains_label_1): Return non-NULL even for CASE_LABEL_EXPR, unless
	inside of a SWITCH_BODY seen during the walk.
	(contains_label_p): Use walk_tree instead of
	walk_tree_without_duplicates, prepare data for contains_label_1 and
	provide own pset.

	* c-c++-common/torture/pr83553.c: New test.

From-SVN: r255988
2017-12-23 09:43:10 +01:00
Martin Jambor 7ad64964da [PR 82027] Also stream opt_info of former_clones
2017-12-22  Martin Jambor  <mjambor@suse.cz>

	PR lto/82027
	* lto-cgraph.c (output_cgraph_opt_summary_p): Also check former
	clones.

testsuite/
	* g++.dg/lto/pr82027_0.C: New test.

From-SVN: r255983
2017-12-22 19:28:59 +01:00
Jakub Jelinek b4b883cee3 backport: re PR c/83448 (ice in get_source_location_for_substring, at input.c:1507)
Backported from mainline
	2017-12-21  Jakub Jelinek  <jakub@redhat.com>

	PR c/83448
	* gimple-ssa-sprintf.c (maybe_warn): Don't call set_caret_index
	if navail is >= dir.len.

	* gcc.c-torture/compile/pr83448.c: New test.
	* gcc.dg/tree-ssa/builtin-snprintf-warn-4.c: New test.

From-SVN: r255972
2017-12-22 09:54:26 +01:00
Jakub Jelinek 7dc36181a0 backport: re PR rtl-optimization/80747 (gcc.dg/tree-ssa/tailrecursion-4.c fails with ICE when compiled with options "-fprofile-use -freorder-blocks-and-partition")
Backported from mainline
	2017-12-21  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/80747
	PR rtl-optimization/83512
	* cfgrtl.c (force_nonfallthru_and_redirect): When splitting
	succ edge from ENTRY, copy partition from e->dest to the newly
	created bb.
	* bb-reorder.c (reorder_basic_blocks_simple): If last_tail is
	ENTRY, use BB_PARTITION of its successor block as current_partition.
	Don't copy partition when splitting succ edge from ENTRY.

	* gcc.dg/pr80747.c: New test.
	* gcc.dg/pr83512.c: New test.

From-SVN: r255971
2017-12-22 09:53:37 +01:00
Jakub Jelinek f0666a4f0a backport: re PR tree-optimization/83523 (ICE: verify_gimple failed (error: statement marked for throw, but doesn't))
Backported from mainline
	2017-12-21  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/83523
	* tree-ssa-math-opts.c (is_widening_mult_p): Return false if
	for INTEGER_TYPE TYPE_OVERFLOW_TRAPS.
	(convert_mult_to_fma): Likewise.

	* g++.dg/tree-ssa/pr83523.C: New test.

From-SVN: r255970
2017-12-22 09:52:28 +01:00
Jakub Jelinek 79cd47fc9d backport: re PR tree-optimization/83521 (ICE: verify_gimple failed (error: invalid operand in unary operation))
Backported from mainline
	2017-12-21  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/83521
	* tree-ssa-phiopt.c (factor_out_conditional_conversion): Use
	gimple_build_assign without code on result of
	fold_build1 (VIEW_CONVERT_EXPR, ...), as it might not create
	a VIEW_CONVERT_EXPR.

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

From-SVN: r255969
2017-12-22 09:51:26 +01:00
Jakub Jelinek 5e35526170 backport: re PR ipa/82801 (Internal compiler error with Eigen and __attribute__((always_inline, flatten)))
Backported from mainline
	2017-12-19  Jakub Jelinek  <jakub@redhat.com>

	PR ipa/82801
	PR ipa/83346
	* ipa-inline.c (flatten_remove_node_hook): New function.
	(ipa_inline): Keep only nodes with flatten attribute at the end of
	the array in the order from ipa_reverse_postorder, only walk that
	portion of array for flattening, if there is more than one such
	node, temporarily register a removal hook and ignore removed nodes.

	* g++.dg/ipa/pr82801.C: New test.

From-SVN: r255968
2017-12-22 09:50:30 +01:00
Uros Bizjak 32a3966ecd re PR target/83467 (ICE: in assign_by_spills, at lra-assigns.c:1476: unable to find a register to spill with -flive-range-shrinkage -m8bit-idiv)
PR target/83467
	* config/i386/i386.md (*ashl<mode>3_mask): Add operand
	constraints to operand 2.
	(*<shift_insn><mode>3_mask): Ditto.
	(*<rotate_insn><mode>3_mask): Ditto.

testsuite/ChangeLog:

	PR target/83467
	* gcc.target/i386/pr83467-1.c: New test.
	* gcc.target/i386/pr83467-2.c: Ditto.

From-SVN: r255956
2017-12-21 21:48:34 +01:00
Bin Cheng 3c6ef044d3 backport: re PR tree-optimization/82726 (ICE in verify_ssa during GIMPLE pass: pcom)
Backport from mainline
	2017-11-15  Bin Cheng  <bin.cheng@arm.com>

	PR tree-optimization/82726
	PR tree-optimization/70754
	* tree-predcom.c (order_drefs_by_pos): New function.
	(combine_chains): Move code setting has_max_use_after to...
	(try_combine_chains): ...here.  New parameter.  Sort combined chains
	according to position information.
	(tree_predictive_commoning_loop): Update call to above function.
	(update_pos_for_combined_chains, pcom_stmt_dominates_stmt_p): New.

	2017-11-15  Bin Cheng  <bin.cheng@arm.com>

	PR tree-optimization/82726
	Revert
	2017-01-23  Bin Cheng  <bin.cheng@arm.com>

	PR tree-optimization/70754
	* tree-predcom.c (stmt_combining_refs): New parameter INSERT_BEFORE.
	(reassociate_to_the_same_stmt): New parameter INSERT_BEFORE.  Insert
	combined stmt before it if not NULL.
	(combine_chains): Process refs reversely and compute dominance point
	for root ref.

	Revert
	2017-02-23  Bin Cheng  <bin.cheng@arm.com>

	PR tree-optimization/79663
	* tree-predcom.c (combine_chains): Process refs in reverse order
	only for ZERO length chains, and add explaining comment.

	gcc/testsuite

	Backport from mainline
	2017-11-15  Bin Cheng  <bin.cheng@arm.com>

	PR tree-optimization/82726
	* gcc.dg/tree-ssa/pr82726.c: New test.

From-SVN: r255828
2017-12-19 15:25:56 +00:00
Sebastian Huber 109836feac RTEMS/PowerPC: Remove 64-bit soft-float multilib
gcc/
	PR target/83387
	* config/rs6000/t-rtems (MULTILIB_REQUIRED): Remove 64-bit soft-float
	multilib.

From-SVN: r255810
2017-12-19 08:20:05 +00:00
Daniel Cederman 9f987b42fc SPARC: Make sure that jump is to a label in errata workaround
In some cases the jump could be to a return instruction and in those cases the
next_active_insn() function tries to follow an invalid pointer which leads to a
crash. This error did not manifest when using a 32-bit version of GCC which is
why I did not detect it before.

gcc/
	* config/sparc/sparc.c (sparc_do_work_around_errata): Make sure
	the jump is to a label.

From-SVN: r255808
2017-12-19 08:07:22 +00:00
John David Anglin 4e138baf89 backport: pa.c (pa_legitimate_address_p): For scaled indexing...
Backport from mainline
	2017-12-03  John David Anglin  <danglin@gcc.gnu.org>

	* config/pa/pa.c (pa_legitimate_address_p): For scaled indexing,
	require base operand is a REG_POINTER prior to reload on targets
	with non-equivalent space registers.

From-SVN: r255762
2017-12-17 17:02:10 +00:00
Jakub Jelinek 99ccf43c70 re PR tree-optimization/83269 (Wrong constant folding)
PR tree-optimization/83269
	* fold-const.c (fold_binary_loc): Perform (-A) - B -> (-B) - A
	subtraction in arg0's type if type is signed and arg0 is unsigned.
	Formatting fix.

	* gcc.c-torture/execute/pr83269.c: New test.

From-SVN: r255729
2017-12-15 23:15:30 +01:00
Jakub Jelinek ea5869d324 backport: re PR tree-optimization/83198 (ICE in format_floating, at gimple-ssa-sprintf.c:1900)
Backported from mainline
	2017-12-14  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/83198
	* gimple-ssa-sprintf.c (format_floating): Set type solely based on
	dir.modifier, regardless of TREE_TYPE (arg).  Assume non-REAL_CST
	value if arg is a REAL_CST with incompatible type.

	* gcc.dg/pr83198.c: New test.
	* gcc.dg/tree-ssa/pr83198.c: New test.

From-SVN: r255728
2017-12-15 23:14:41 +01:00
Jakub Jelinek a9a6b2e8cf backport: re PR tree-optimization/80631 (Compiling with -O3 -mavx2 gives wrong code)
Backported from mainline
	2017-12-12  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/80631
	* tree-vect-loop.c (get_initial_def_for_reduction): Fix comment typo.
	(vect_create_epilog_for_reduction): Add INDUC_VAL argument, for
	INTEGER_INDUC_COND_REDUCTION use INDUC_VAL instead of
	hardcoding zero as the value if COND_EXPR is never true.  For
	INTEGER_INDUC_COND_REDUCTION don't emit the final COND_EXPR if
	INDUC_VAL is equal to INITIAL_DEF.
	(vectorizable_reduction): Compute INDUC_VAL for
	vect_create_epilog_for_reduction, if no value is suitable, don't
	use INTEGER_INDUC_COND_REDUCTION for now.  Formatting fixes.

	* gcc.dg/vect/pr80631-1.c: New test.
	* gcc.dg/vect/pr80631-2.c: New test.

	PR tree-optimization/80631
	* gcc.target/i386/avx2-pr80631.c: New test.

From-SVN: r255726
2017-12-15 23:12:46 +01:00
Jakub Jelinek af3b2e0538 backport: re PR target/81906 (Calls to rint() wrongly optimized away starting in g++ 6)
Backported from mainline
	2017-12-08  Joseph Myers  <joseph@codesourcery.com>
		    Alexander Monakov  <amonakov@ispras.ru>
		    Jakub Jelinek  <jakub@redhat.com>

	PR target/81906
	* config/i386/i386.c (ix86_expand_rint): Handle flag_rounding_math.

	* gcc.target/i386/pr81906.c: New test.

From-SVN: r255725
2017-12-15 23:11:33 +01:00
Jakub Jelinek 25d8a020e0 backport: re PR sanitizer/81212 (-Wreturn-type is disabled when used together with -fsanitize=return)
Backported from mainline
	2017-12-02  Jakub Jelinek  <jakub@redhat.com>

	PR c++/81212
	* tree-cfg.c (pass_warn_function_return::execute): Handle
	__builtin_ubsan_handle_missing_return like __builtin_unreachable
	with BUILTINS_LOCATION.

	* g++.dg/ubsan/pr81212.C: New test.

From-SVN: r255722
2017-12-15 23:09:50 +01:00
Jakub Jelinek e2e1e8d9f8 backport: re PR target/78643 (ICE in convert_move, at expr.c:230)
Backported from mainline
	2017-12-02  Jakub Jelinek  <jakub@redhat.com>

	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 TYPE_MODE
	instead of DECL_MODE.

	* gcc.target/i386/pr80583.c: New test.

From-SVN: r255721
2017-12-15 23:09:07 +01:00
Jakub Jelinek ab26ce4518 backport: re PR target/80819 (Useless store to the stack in _mm_set_epi64x with SSE4 -mno-avx)
Backported from mainline
	2017-11-29  Jakub Jelinek  <jakub@redhat.com>

	PR target/80819
	* config/i386/sse.md (vec_concatv2di): Remove * from (=Yr,0,*rm)
	alternative.

	* gcc.target/i386/pr80819-1.c: New test.
	* gcc.target/i386/pr80819-2.c: New test.

From-SVN: r255720
2017-12-15 23:08:20 +01:00
Jakub Jelinek 7e27191cf5 backport: re PR rtl-optimization/81553 (ICE in immed_wide_int_const, at emit-rtl.c:607)
Backported from mainline
	2017-11-25  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/81553
	* combine.c (simplify_if_then_else): In (if_then_else COND (OP Z C1) Z)
	to (OP Z (mult COND (C1 * STORE_FLAG_VALUE))) optimization, if OP
	is a shift where C1 has different mode than the whole shift, use C1's
	mode for MULT rather than the shift's mode.

	* gcc.c-torture/compile/pr81553.c: New test.

From-SVN: r255717
2017-12-15 23:05:00 +01:00
Jakub Jelinek e57525d514 backport: re PR sanitizer/83014 (ICE in pretty-print with -fsanitize=bounds)
Backported from mainline
	2017-11-24  Jakub Jelinek  <jakub@redhat.com>
 
	PR sanitizer/83014
	* ubsan.c (ubsan_type_descriptor): Use pp_unsigned_wide_integer
	instead of pp_printf with HOST_WIDE_INT_PRINT_DEC.  Avoid calling
	tree_to_uhwi twice.

	* gcc.dg/ubsan/pr83014.c: New test.

From-SVN: r255715
2017-12-15 22:58:13 +01:00
Jakub Jelinek 5a8687cc52 backport: tree-object-size.c (pass_through_call): Do not handle BUILT_IN_STPNCPY_CHK which is not a pass through call.
Backported from mainline
	2017-11-24  Jakub Jelinek  <jakub@redhat.com>

	* tree-object-size.c (pass_through_call): Do not handle
	BUILT_IN_STPNCPY_CHK which is not a pass through call.

	* gcc.dg/builtin-object-size-18.c: New test.

From-SVN: r255714
2017-12-15 22:57:19 +01:00
Jakub Jelinek 8ea87c5f83 backport: re PR middle-end/82253 (ICE in convert_move, at expr.c:604)
Backported from mainline
	2017-11-23  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/82253
	* expr.c (expand_assignment): For CONCAT to_rtx, complex type from and
	bitpos/bitsize covering the whole destination, use store_expr only if
	the complex mode is the same.  Otherwise, use expand_normal and if
	it returns CONCAT, subreg each part separately instead of trying to
	subreg the whole result.

	* gfortran.dg/pr82253.f90: New test.

From-SVN: r255711
2017-12-15 22:54:15 +01:00
Jakub Jelinek 98a409be9d backport: re PR debug/83084 (-fcompare-debug failure on ppc64le)
Backported from mainline
	2017-11-22  Jakub Jelinek  <jakub@redhat.com>

	PR debug/83084
	* valtrack.c (propagate_for_debug_subst, propagate_for_debug): Reset
	debug insns if they would contain UNSPEC_VOLATILE or volatile asm.
	(dead_debug_insert_temp): Likewise, but also ignore even non-volatile
	asm.

	* g++.dg/opt/pr83084.C: New test.

From-SVN: r255710
2017-12-15 22:53:29 +01:00
Jakub Jelinek 98ea6f03f9 backport: re PR target/82880 (gcc --help=target --help=optimizers hangs on mips)
Backported from mainline
	2017-11-21  James Cowgill  <James.Cowgill@imgtec.com>
		    Jakub Jelinek  <jakub@redhat.com>

	PR target/82880
	* config/mips/frame-header-opt.c (mips_register_frame_header_opt):
	Remove static keyword from f variable.

	* gcc.dg/opts-8.c: New test.

From-SVN: r255709
2017-12-15 22:52:06 +01:00
Richard Biener 8c633e4d27 re PR bootstrap/83439 (Bootstrap failure with --enable-checking=yes,rtl,extra)
2017-12-15  Richard Biener  <rguenther@suse.de>

	PR bootstrap/83439
	* tree-ssa-pre.c (eliminate_dom_walker::before_dom_children):
	Adjust remaining gimple_set_modified to use the modified
	variable instead.

From-SVN: r255704
2017-12-15 20:45:36 +00:00
Eric Botcazou 9f671acc02 re PR target/66488 (segfault on sizeof(long) < sizeof(void*) and large GCC memory usage)
PR target/66488
	* ggc-page.c (HOST_BITS_PER_PTR): Do not define here...
	* hwint.h (HOST_BITS_PER_PTR): ...but here instead.
	* config/i386/xm-mingw32.h (HOST_BITS_PER_PTR): Delete.

From-SVN: r255688
2017-12-15 11:31:42 +00:00