aboutsummaryrefslogtreecommitdiff
path: root/gcc/ifcvt.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2015-11-19 09:49:59 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2015-11-19 09:49:59 +0100
commitdfc3d7a8a25f7235578a4f4547aa95dacf53fcb6 (patch)
tree47232c094e52e451e75dcf381b4992ec2a034aae /gcc/ifcvt.c
parentbb35ccb1efb2c91d1eab17fc4fb26c8b2f32ebeb (diff)
downloadgcc-dfc3d7a8a25f7235578a4f4547aa95dacf53fcb6.zip
gcc-dfc3d7a8a25f7235578a4f4547aa95dacf53fcb6.tar.gz
gcc-dfc3d7a8a25f7235578a4f4547aa95dacf53fcb6.tar.bz2
re PR rtl-optimization/68376 (wrong code at -O1 and above on x86_64-linux-gnu)
PR rtl-optimization/68376 * ifcvt.c (noce_try_abs): Disable one_cmpl optimization if encountering x <= 0 ? ~x : x or x > 0 ? ~x : x. * gcc.c-torture/execute/pr68376-1.c: New test. * gcc.c-torture/execute/pr68376-2.c: New test. From-SVN: r230596
Diffstat (limited to 'gcc/ifcvt.c')
-rw-r--r--gcc/ifcvt.c45
1 files changed, 41 insertions, 4 deletions
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index 56e4ed42..eb5cae5 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -2595,12 +2595,49 @@ noce_try_abs (struct noce_if_info *if_info)
/* Work around funny ideas get_condition has wrt canonicalization.
Note that these rtx constants are known to be CONST_INT, and
- therefore imply integer comparisons. */
+ therefore imply integer comparisons.
+ The one_cmpl case is more complicated, as we want to handle
+ only x < 0 ? ~x : x or x >= 0 ? ~x : x but not
+ x <= 0 ? ~x : x or x > 0 ? ~x : x, as the latter two
+ have different result for x == 0. */
if (c == constm1_rtx && GET_CODE (cond) == GT)
- ;
+ {
+ if (one_cmpl && negate)
+ return FALSE;
+ }
else if (c == const1_rtx && GET_CODE (cond) == LT)
- ;
- else if (c != CONST0_RTX (GET_MODE (b)))
+ {
+ if (one_cmpl && !negate)
+ return FALSE;
+ }
+ else if (c == CONST0_RTX (GET_MODE (b)))
+ {
+ if (one_cmpl)
+ switch (GET_CODE (cond))
+ {
+ case GT:
+ if (!negate)
+ return FALSE;
+ break;
+ case GE:
+ /* >= 0 is the same case as above > -1. */
+ if (negate)
+ return FALSE;
+ break;
+ case LT:
+ if (negate)
+ return FALSE;
+ break;
+ case LE:
+ /* <= 0 is the same case as above < 1. */
+ if (!negate)
+ return FALSE;
+ break;
+ default:
+ return FALSE;
+ }
+ }
+ else
return FALSE;
/* Determine what sort of operation this is. */