public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Validation of adding left shift stmt at GIMPLE - [Custom GCC plugin]]
@ 2022-02-18 19:02 Shubham Narlawar
  2022-02-18 19:45 ` Andrew Pinski
  0 siblings, 1 reply; 11+ messages in thread
From: Shubham Narlawar @ 2022-02-18 19:02 UTC (permalink / raw)
  To: GCC Development

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

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

end of thread, other threads:[~2022-03-28  8:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-18 19:02 Validation of adding left shift stmt at GIMPLE - [Custom GCC plugin]] Shubham Narlawar
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

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