diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-12-15 22:05:00 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-12-15 22:05:00 +0000 |
commit | 26afe5f566675a56550c1e564073e3ff7aa97326 (patch) | |
tree | 8564300dc1ffc0b9991bef601c66d264f50b7a9f | |
parent | 62307242695fa13d6a7389b8f1c4bc0735bf8c8e (diff) | |
download | gcc-26afe5f566675a56550c1e564073e3ff7aa97326.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@255717 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/combine.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr81553.c | 10 |
4 files changed, 30 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e26cd272acf..fac2f235605 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,6 +1,14 @@ 2017-12-15 Jakub Jelinek <jakub@redhat.com> 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. + 2017-11-24 Jakub Jelinek <jakub@redhat.com> PR sanitizer/83014 diff --git a/gcc/combine.c b/gcc/combine.c index c6257f60488..1cd6895ca17 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -6541,11 +6541,15 @@ simplify_if_then_else (rtx x) if (z) { - temp = subst (simplify_gen_relational (true_code, m, VOIDmode, + machine_mode cm = m; + if ((op == ASHIFT || op == LSHIFTRT || op == ASHIFTRT) + && GET_MODE (c1) != VOIDmode) + cm = GET_MODE (c1); + temp = subst (simplify_gen_relational (true_code, cm, VOIDmode, cond_op0, cond_op1), pc_rtx, pc_rtx, 0, 0, 0); - temp = simplify_gen_binary (MULT, m, temp, - simplify_gen_binary (MULT, m, c1, + temp = simplify_gen_binary (MULT, cm, temp, + simplify_gen_binary (MULT, cm, c1, const_true_rtx)); temp = subst (temp, pc_rtx, pc_rtx, 0, 0, 0); temp = simplify_gen_binary (op, m, gen_lowpart (m, z), temp); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 372fe759edc..f94333f7622 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2017-12-15 Jakub Jelinek <jakub@redhat.com> Backported from mainline + 2017-11-25 Jakub Jelinek <jakub@redhat.com> + + PR rtl-optimization/81553 + * gcc.c-torture/compile/pr81553.c: New test. + 2017-11-24 Jakub Jelinek <jakub@redhat.com> PR sanitizer/83014 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr81553.c b/gcc/testsuite/gcc.c-torture/compile/pr81553.c new file mode 100644 index 00000000000..ae33b169824 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr81553.c @@ -0,0 +1,10 @@ +/* PR rtl-optimization/81553 */ + +int a, b, c, d; + +void +foo (void) +{ + d = 1 >> c >> 1; + b = ~(209883449764912897ULL & d) << (0 >= a) | ~d; +} |