-
- Downloads
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.
Showing
- gcc/doc/sourcebuild.texi 4 additions, 0 deletionsgcc/doc/sourcebuild.texi
- gcc/match.pd 17 additions, 5 deletionsgcc/match.pd
- gcc/testsuite/gcc.dg/fold-copysign-1.c 5 additions, 2 deletionsgcc/testsuite/gcc.dg/fold-copysign-1.c
- gcc/testsuite/gcc.dg/pr55152-2.c 4 additions, 2 deletionsgcc/testsuite/gcc.dg/pr55152-2.c
- gcc/testsuite/gcc.dg/tree-ssa/abs-4.c 6 additions, 3 deletionsgcc/testsuite/gcc.dg/tree-ssa/abs-4.c
- gcc/testsuite/gcc.dg/tree-ssa/backprop-6.c 6 additions, 3 deletionsgcc/testsuite/gcc.dg/tree-ssa/backprop-6.c
- gcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c 4 additions, 2 deletionsgcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c
- gcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c 2 additions, 2 deletionsgcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c
- gcc/testsuite/lib/target-supports.exp 24 additions, 0 deletionsgcc/testsuite/lib/target-supports.exp
Loading
Please register or sign in to comment