Skip to content
Snippets Groups Projects
Commit 7cbe41d3 authored by Tamar Christina's avatar Tamar Christina
Browse files

middle-end: Don't apply copysign optimization if target does not implement optab [PR112468]

Currently GCC does not treat IFN_COPYSIGN the same as the copysign tree expr.
The latter has a libcall fallback and the IFN can only do optabs.

Because of this the change I made to optimize copysign only works if the
target has impemented the optab, but it should work for those that have the
libcall too.

More annoyingly if a target has vector versions of ABS and NEG but not COPYSIGN
then the change made them lose vectorization.

The proper fix for this is to treat the IFN the same as the tree EXPR and to
enhance expand_COPYSIGN to also support vector calls.

I have such a patch for GCC 15 but it's quite big and too invasive for stage-4.
As such this is a minimal fix, just don't apply the transformation and leave
targets which don't have the optab unoptimized.

Targets list for check_effective_target_ifn_copysign was gotten by grepping for
copysign and looking at the optab.

gcc/ChangeLog:

	PR tree-optimization/112468
	* doc/sourcebuild.texi: Document ifn_copysign.
	* match.pd: Only apply transformation if target supports the IFN.

gcc/testsuite/ChangeLog:

	PR tree-optimization/112468
	* gcc.dg/fold-copysign-1.c: Modify tests based on if target supports
	IFN_COPYSIGN.
	* gcc.dg/pr55152-2.c: Likewise.
	* gcc.dg/tree-ssa/abs-4.c: Likewise.
	* gcc.dg/tree-ssa/backprop-6.c: Likewise.
	* gcc.dg/tree-ssa/copy-sign-2.c: Likewise.
	* gcc.dg/tree-ssa/mult-abs-2.c: Likewise.
	* lib/target-supports.exp (check_effective_target_ifn_copysign): New.
parent 113475d0
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment