public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH GCC]Look into unnecessary conversion when checking mult_op in get_shiftadd_cost
@ 2015-09-02  3:50 Bin Cheng
  2015-09-02 12:32 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Bin Cheng @ 2015-09-02  3:50 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 484 bytes --]

Hi,
When calling get_shiftadd_cost, the mult_op is stripped at caller places.
We should look into unnecessary conversion in op1 before checking equality,
otherwise it computes wrong shiftadd cost.  This patch picks this small
issue up.

Bootstrap and test on x86_64 and aarch64 along with other patches.  Is it
OK?

Thanks,
bin

2015-08-31  Bin Cheng  <bin.cheng@arm.com>

	* tree-ssa-loop-ivopts.c (get_shiftadd_cost): Look into
	unnecessary type conversion for OP1.

[-- Attachment #2: pr66388_3-20150824.txt --]
[-- Type: text/plain, Size: 764 bytes --]

Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
--- gcc/tree-ssa-loop-ivopts.c	(revision 227163)
+++ gcc/tree-ssa-loop-ivopts.c	(working copy)
@@ -3884,12 +4038,14 @@ get_shiftadd_cost (tree expr, machine_mode mode, c
   int m = exact_log2 (int_cst_value (cst));
   int maxm = MIN (BITS_PER_WORD, GET_MODE_BITSIZE (mode));
   int as_cost, sa_cost;
-  bool mult_in_op1;
+  bool mult_in_op1 = false;
 
   if (!(m >= 0 && m < maxm))
     return false;
 
-  mult_in_op1 = operand_equal_p (op1, mult, 0);
+  if (operand_equal_p (op1, mult, 0)
+      || operand_equal_p (STRIP_NOPS (op1), mult, 0))
+    mult_in_op1 = true;
 
   as_cost = add_cost (speed, mode) + shift_cost (speed, mode, m);
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH GCC]Look into unnecessary conversion when checking mult_op in get_shiftadd_cost
  2015-09-02  3:50 [PATCH GCC]Look into unnecessary conversion when checking mult_op in get_shiftadd_cost Bin Cheng
@ 2015-09-02 12:32 ` Richard Biener
  2015-09-15  5:56   ` Bin.Cheng
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2015-09-02 12:32 UTC (permalink / raw)
  To: Bin Cheng; +Cc: GCC Patches

On Wed, Sep 2, 2015 at 5:50 AM, Bin Cheng <bin.cheng@arm.com> wrote:
> Hi,
> When calling get_shiftadd_cost, the mult_op is stripped at caller places.
> We should look into unnecessary conversion in op1 before checking equality,
> otherwise it computes wrong shiftadd cost.  This patch picks this small
> issue up.
>
> Bootstrap and test on x86_64 and aarch64 along with other patches.  Is it
> OK?

Just do STRIP_NOPS (op1) unconditionally?  Thus

  STRIP_NOPS (op1);
  mult_in_op1 = operand_equal_p (op1, mult, 0);

ok with that change.

Thanks,
Richard.

> Thanks,
> bin
>
> 2015-08-31  Bin Cheng  <bin.cheng@arm.com>
>
>         * tree-ssa-loop-ivopts.c (get_shiftadd_cost): Look into
>         unnecessary type conversion for OP1.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH GCC]Look into unnecessary conversion when checking mult_op in get_shiftadd_cost
  2015-09-02 12:32 ` Richard Biener
@ 2015-09-15  5:56   ` Bin.Cheng
  0 siblings, 0 replies; 3+ messages in thread
From: Bin.Cheng @ 2015-09-15  5:56 UTC (permalink / raw)
  To: Richard Biener; +Cc: Bin Cheng, GCC Patches

On Wed, Sep 2, 2015 at 8:32 PM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Wed, Sep 2, 2015 at 5:50 AM, Bin Cheng <bin.cheng@arm.com> wrote:
>> Hi,
>> When calling get_shiftadd_cost, the mult_op is stripped at caller places.
>> We should look into unnecessary conversion in op1 before checking equality,
>> otherwise it computes wrong shiftadd cost.  This patch picks this small
>> issue up.
>>
>> Bootstrap and test on x86_64 and aarch64 along with other patches.  Is it
>> OK?
>
> Just do STRIP_NOPS (op1) unconditionally?  Thus
>
>   STRIP_NOPS (op1);
>   mult_in_op1 = operand_equal_p (op1, mult, 0);
>
> ok with that change.
Patch committed as suggested.

Thanks,
bin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-15  5:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-02  3:50 [PATCH GCC]Look into unnecessary conversion when checking mult_op in get_shiftadd_cost Bin Cheng
2015-09-02 12:32 ` Richard Biener
2015-09-15  5:56   ` Bin.Cheng

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).