This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi, I decided to split my previous patch into two different patches, one for floating point and one for integer. This is the floating point version as we can use copysign here which should allow for more cases to be optimized and even by a phiopt which uses match-and-simplify (I hope to be able to submit that during stage 1). This patch adds the following transformations: Transform (X > 0.0 ? 1.0 : -1.0) into copysign(1, X). Transform (X >= 0.0 ? 1.0 : -1.0) into copysign(1, X). Transform (X < 0.0 ? 1.0 : -1.0) into copysign(1,-X). Transform (X <= 0.0 ? 1.0 : -1.0) into copysign(1,-X). Transform (X > 0.0 ? -1.0 : 1.0) into copysign(1,-X). Transform (X >= 0.0 ? -1.0 : 1.0) into copysign(1,-X). Transform (X < 0.0 ? -1.0 : 1.0) into copysign(1,X). Transform (X <= 0.0 ? -1.0 : 1.0) into copysign(1,X). Transform X * copysign (1.0, X) into abs(X). Transform X * copysign (1.0, -X) into -abs(X). Transform copysign (-1.0, X) into copysign (1.0, X). The last one is there so if someone decides to writes -1.0 instead of 1.0 in the code we would get the optimization still. OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions. Thanks, Andrew Pinski ChangeLog: * match.pd (X >/>=/</<= 0 ? 1.0 : -1.0): New patterns. (X * copysign (1.0, X)): New pattern. (X * copysign (1.0, -X)): New pattern. (copysign (-1.0, X)): New pattern. testsuite/ChangeLog: * gcc.dg/tree-ssa/copy-sign-1.c: New testcase. * gcc.dg/tree-ssa/copy-sign-2.c: New testcase. * gcc.dg/tree-ssa/mult-abs-2.c: New testcase.
Attachment:
copysign-1.diff.txt
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |