This is the mail archive of the gcc@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]

[RFC PR43721] Optimize a/b and a%b to single divmod call


Hi,
I have attached revamped version of Kugan's patch
(https://gcc.gnu.org/ml/gcc/2013-06/msg00100.html) for PR43721.
Test-case: http://pastebin.com/QMfpXLD9
divmod pass dump: http://pastebin.com/yMY1ikCp
Assembly: http://pastebin.com/kk2HZpvA

The approach I took is similar to sincos pass, which involves two parts:
a) divmod pass that transforms:
t1 = a / b;
t2 = a % b;
to the following sequence:
complex_tmp = DIVMOD (a, b);
t1 = REALPART_EXPR(a);
t2 = IMAGPART_EXPR(b);

b) DIVMOD(a, b) is represented as an internal-fn and is expanded by
expand_DIVMOD().
I am not sure if I have done this correctly. I was somehow looking to
reuse expand_divmod() but am not able to figure out how to do that
(AFAIU expand_divmod() strictly returns either the quotient or
remainder but never both which is what I want), so ended up with
manually expanding to rtx.

While going through the sincos pass in execute_cse_sincos_1, I didn't
understand the following:
 if (gimple_purge_dead_eh_edges (gimple_bb (stmt)))
          cfg_changed = true;
Um why is the call to gimple_purge_dead_eh_edges necessary here?

A silly question, what options to pass to gcc to print statistics ? I
added statistics_counter_event to keep track of number of calls
inserted/used but not sure how to print them :/

I would be grateful for suggestions for improving the patch.

Thank you,
Prathamesh

Attachment: ChangeLog.txt
Description: Text document

Attachment: patch.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]