From: Kugan <kugan.vivekanandarajah@linaro.org>
To: Uros Bizjak <ubizjak@gmail.com>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
Richard Biener <richard.guenther@gmail.com>
Cc: Jakub Jelinek <jakub@redhat.com>
Subject: Re: [PATCH 2/2] Enable elimination of zext/sext
Date: Thu, 28 Aug 2014 03:46:00 -0000 [thread overview]
Message-ID: <53FEA5F0.9070906@linaro.org> (raw)
In-Reply-To: <53FDD6CA.7000400@linaro.org>
On 27/08/14 23:02, Kugan wrote:
> On 27/08/14 20:01, Uros Bizjak wrote:
>> Hello!
>>
>>> 2014-08-07 Kugan Vivekanandarajah <kuganv@linaro.org>
>>>
>>> * calls.c (precompute_arguments): Check
>>> promoted_for_signed_and_unsigned_p and set the promoted mode.
>>> (promoted_for_signed_and_unsigned_p): New function.
>>> (expand_expr_real_1): Check promoted_for_signed_and_unsigned_p
>>> and set the promoted mode.
>>> * expr.h (promoted_for_signed_and_unsigned_p): New function definition.
>>> * cfgexpand.c (expand_gimple_stmt_1): Call emit_move_insn if
>>> SUBREG is promoted with SRP_SIGNED_AND_UNSIGNED.
>>
>> This patch regresses:
>>
>> Running target unix
>> FAIL: libgomp.fortran/simd7.f90 -O2 execution test
>> FAIL: libgomp.fortran/simd7.f90 -Os execution test
>>
>
> [snip]
>
>> When compiling this code, we have:
>>
>> lhs = _63
>> target = (subreg/s/v/u:SI (reg:DI 145 [ D.1694 ]) 0)
>> temp = (subreg:SI (reg:DI 540) 0)
>>
>> So, the code assumes that it is possible to copy (reg:DI 540) directly
>> to (reg:DI 154). However, this is not the case, since we still have
>> garbage in the top 32bits.
>>
>> Reverting the part above fixes the runtime failure, since (insn 599) is now:
>>
>> (insn 599 598 0 (set (reg:DI 145 [ D.1694 ])
>> (zero_extend:DI (subreg:SI (reg:DI 540) 0))) -1
>> (nil))
>>
>> It looks to me that we have also to check the temp with SUBREG_PROMOTED_*.
>
> Sorry for the breakage. I am looking into this now and I can reproduce
> it on qemu-alpha.
>
> I have noticed the following VRP data which is used in deciding this
> erroneous removal. It seems suspicious to me.
>
> _343: [2147483652, 2147483715]
> _344: [8, 134]
> _345: [8, 134]
>
> _343 = ivtmp.179_52 + 2147483645;
> _344 = _343 * 2;
> _345 = (integer(kind=4)) _344;
>
> Error comes from the third statement.
In tree-vrp.c, in extract_range_from_binary_expr_1, there is a loss of
precision and the value_range is truncated. For the test-case provided
by Uros, it is
_344 = _343 * 2;
[...,0x100000008], precision = 384
[...,0x100000086], precision = 384
and it is converted to following when it goes from wide_int to tree.
[8, 134]
How about doing something like this to fix it.
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index d16fd8a..c0fb902 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -2625,6 +2625,8 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
<wi::extended_tree <WIDE_INT_MAX_PRECISION * 2> > vrp_int_cst;
vrp_int sizem1 = wi::mask <vrp_int> (prec, false);
vrp_int size = sizem1 + 1;
+ vrp_int type_min = vrp_int_cst (TYPE_MIN_VALUE (expr_type));
+ vrp_int type_max = vrp_int_cst (TYPE_MAX_VALUE (expr_type));
/* Extend the values using the sign of the result to PREC2.
From here on out, everthing is just signed math no matter
@@ -2688,7 +2690,9 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
/* diff = max - min. */
prod2 = prod3 - prod0;
- if (wi::geu_p (prod2, sizem1))
+ if (wi::geu_p (prod2, sizem1)
+ || wi::lts_p (prod0, type_min)
+ || wi::gts_p (prod3, type_max))
{
/* the range covers all values. */
set_value_range_to_varying (vr);
If this looks reasonable I will do proper testing and post the results
with the Changelog.
Thanks,
Kugan
next prev parent reply other threads:[~2014-08-28 3:46 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-27 10:01 Uros Bizjak
2014-08-27 10:07 ` Richard Biener
2014-08-27 10:32 ` Uros Bizjak
2014-08-27 10:32 ` Richard Biener
2014-09-01 8:48 ` Jakub Jelinek
2014-09-01 8:54 ` Uros Bizjak
2014-08-28 7:50 ` Kugan
2014-08-28 8:57 ` Richard Biener
2014-09-04 3:41 ` Kugan
2014-09-04 13:00 ` Richard Biener
2014-09-05 1:33 ` Kugan
2014-09-05 9:51 ` Richard Biener
2014-09-07 9:51 ` Kugan
2014-09-08 9:48 ` Richard Biener
2014-09-09 10:06 ` Kugan
2014-09-09 10:28 ` Richard Biener
2014-11-09 23:30 ` [RFC] Elimination of zext/sext - type promotion pass Kugan
2014-11-10 12:56 ` Richard Biener
2015-05-01 4:41 ` Kugan
2015-05-08 12:48 ` Richard Biener
2015-06-01 23:20 ` Kugan
2015-06-19 2:55 ` Kugan
2015-07-28 11:05 ` Richard Biener
2015-08-05 0:12 ` kugan
2015-08-05 9:10 ` Richard Biener
2014-08-27 13:02 ` [PATCH 2/2] Enable elimination of zext/sext Kugan
2014-08-28 3:46 ` Kugan [this message]
2014-08-28 6:44 ` Marc Glisse
2014-08-28 7:29 ` Kugan
-- strict thread matches above, loose matches on Subject: below --
2014-06-24 11:48 [PATCH 0/2] Zext/sext elimination using value range Kugan
2014-06-24 11:53 ` [PATCH 2/2] Enable elimination of zext/sext Kugan
2014-06-24 12:21 ` Jakub Jelinek
2014-06-25 8:15 ` Kugan
2014-06-25 8:36 ` Jakub Jelinek
2014-07-07 6:55 ` Kugan
2014-07-10 12:15 ` Richard Biener
2014-07-11 11:52 ` Kugan
2014-07-11 12:47 ` Richard Biener
2014-07-14 2:58 ` Kugan
2014-07-14 20:11 ` Bernhard Reutner-Fischer
2014-07-23 14:22 ` Richard Biener
2014-08-01 4:51 ` Kugan
2014-08-01 11:16 ` Richard Biener
2014-08-01 16:04 ` Kugan
2014-08-03 23:56 ` Kugan
2014-08-05 14:18 ` Richard Biener
2014-08-05 14:21 ` Jakub Jelinek
2014-08-06 12:09 ` Richard Biener
2014-08-06 13:22 ` Kugan
2014-08-06 13:29 ` Richard Biener
2014-08-07 5:25 ` Kugan
2014-08-07 8:09 ` Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53FEA5F0.9070906@linaro.org \
--to=kugan.vivekanandarajah@linaro.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=richard.guenther@gmail.com \
--cc=ubizjak@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).