public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Shubham Narlawar <gsocshubham@gmail.com>
To: GCC Development <gcc@gcc.gnu.org>
Subject: Validation of adding left shift stmt at GIMPLE - [Custom GCC plugin]]
Date: Sat, 19 Feb 2022 00:32:53 +0530	[thread overview]
Message-ID: <CAN=hqDCaz7uzgQjgpeE8OJpEp80OObkN49X8bkeynvKsoV_eaw@mail.gmail.com> (raw)

Hello,

I want to know whether it is correct to add left shift instruction to
a constant expression statement like "_3 + 4"?

I am trying to add a left shift instruction in between below GIMPLE
instructions -

  <bb 2> :
  instrn_buffer.0_1 = instrn_buffer;
  _2 = tree.cnt;
  _3 = (int) _2;
  _4 = _3 + 4;
  _5 = (unsigned int) _4;        // I want to add left shift here
  D.2993 = __builtin_riscv_sfploadi (instrn_buffer.0_1, 0, _5);
//this is "stmt"

I am using this snippet in custom gcc plugin -

          tree lshift_tmp = make_temp_ssa_name (integer_type_node,
NULL, "slli");
          gimple *lshift = gimple_build_assign (lshift_tmp, LSHIFT_EXPR, parm,
                                                      build_int_cst
(integer_type_node, 8));
          gsi_insert_before(&gsi, lshift, GSI_NEW_STMT);
          //Update function call
          gimple_call_set_arg (stmt, idx, lshift_tmp);
          update_stmt (stmt);
          update_ssa (TODO_update_ssa);

from which above GIMPLE IR is modified to -

  <bb 2> :
  instrn_buffer.0_1 = instrn_buffer;
  _2 = tree.cnt;
  _3 = (int) _2;
  _4 = _3 + 4;
  _5 = (unsigned int) _4;
  slli_24 = _5 << 8;
  D.2993 = __builtin_riscv_sfploadi (instrn_buffer.0_1, 0, slli_24);


1. When I run above code, either dominator tree validation or tree cfg
fixup is failing which suggests to me it is either incorrect to apply
such left shift or some more work is missing?

2. I followed how a left shift gimple assignment is generated but
still feels there is something wrong with the above generation. Can
someone please point me out?

Thanks in advance! As always, the GCC community and its members are
very supportive, responsive and helpful!

Regards,
Shubham

             reply	other threads:[~2022-02-18 19:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-18 19:02 Shubham Narlawar [this message]
2022-02-18 19:45 ` Andrew Pinski
2022-02-20 18:45   ` Shubham Narlawar
2022-02-20 22:40     ` Andrew Pinski
2022-02-21  7:32       ` Richard Biener
2022-02-22  7:38         ` Shubham Narlawar
2022-02-22 10:25           ` Richard Biener
2022-02-22 13:10             ` Shubham Narlawar
2022-02-23  7:22               ` Richard Biener
2022-03-27 17:44                 ` Shubham Narlawar
2022-03-28  8:37                   ` 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='CAN=hqDCaz7uzgQjgpeE8OJpEp80OObkN49X8bkeynvKsoV_eaw@mail.gmail.com' \
    --to=gsocshubham@gmail.com \
    --cc=gcc@gcc.gnu.org \
    /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).