public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Some really strange GIMPLE
@ 2021-04-27 20:10 Gary Oblock
  2021-04-27 20:26 ` David Malcolm
  2021-04-27 23:17 ` Andrew Pinski
  0 siblings, 2 replies; 4+ messages in thread
From: Gary Oblock @ 2021-04-27 20:10 UTC (permalink / raw)
  To: gcc

I'm chasing a bug and I used Creduce to produce a
reduced test case. However, that's really beside to
point.

I this file:
--------------------------------
typedef struct basket {
} a;
long b;
a *basket;
int d, c, e;
a *flake[2];
void primal_bea_mpp();
void primal_net_simplex() {
  flake[1] = &basket[1];
  primal_bea_mpp(d, d, d, b, flake, 0, e, c, c, d);
}
--------------------------------
Produces this GIMPLE:
---------------------------------
;; Function primal_net_simplex (primal_net_simplex, funcdef_no=3, decl_uid=4447, cgraph_uid=16, symbol_order=41) (executed once)

primal_net_simplex ()
{
  <bb 2> [local count: 1073741824]:
  _1 = basket;
  static struct a * flake[2];
struct a *[2]
  flake[1] = _1;
  _2 = d;
  _3 = c;
  _4 = e;
  _5 = b;
  primal_bea_mpp (_2, _2, _2, _5, &flake, 0, _4, _3, _3, _2);
  return;

}
--------------------------------------
These standard calls were used to dump this:

  FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node)
  {
    struct function *func = DECL_STRUCT_FUNCTION ( node->decl);
    dump_function_header ( file, func->decl, (dump_flags_t)0);
    dump_function_to_file ( func->decl, file, (dump_flags_t)0);
  }

The GIMPLE above looks malformed to me. Is that the case
or am I not grasping what's going on here?

Note, I wouldn't be asking this question if this wasn't at the start of
my pass and looking at stuff I hadn't modified.

Thanks,

Gary


CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and contains information that is confidential and proprietary to Ampere Computing or its subsidiaries. It is to be used solely for the purpose of furthering the parties' business relationship. Any unauthorized review, copying, or distribution of this email (or any attachments thereto) is strictly prohibited. If you are not the intended recipient, please contact the sender immediately and permanently delete the original and any copies of this email and any attachments thereto.

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

* Re: Some really strange GIMPLE
  2021-04-27 20:10 Some really strange GIMPLE Gary Oblock
@ 2021-04-27 20:26 ` David Malcolm
  2021-04-27 23:17 ` Andrew Pinski
  1 sibling, 0 replies; 4+ messages in thread
From: David Malcolm @ 2021-04-27 20:26 UTC (permalink / raw)
  To: Gary Oblock, gcc

On Tue, 2021-04-27 at 20:10 +0000, Gary Oblock via Gcc wrote:
> I'm chasing a bug and I used Creduce to produce a
> reduced test case. However, that's really beside to
> point.
> 
> I this file:
> --------------------------------
> typedef struct basket {
> } a;
> long b;
> a *basket;
> int d, c, e;
> a *flake[2];
> void primal_bea_mpp();
> void primal_net_simplex() {
>   flake[1] = &basket[1];
>   primal_bea_mpp(d, d, d, b, flake, 0, e, c, c, d);
> }
> --------------------------------
> Produces this GIMPLE:
> ---------------------------------
> ;; Function primal_net_simplex (primal_net_simplex, funcdef_no=3,
> decl_uid=4447, cgraph_uid=16, symbol_order=41) (executed once)
> 
> primal_net_simplex ()
> {
>   <bb 2> [local count: 1073741824]:
>   _1 = basket;
>   static struct a * flake[2];
> struct a *[2]
>   flake[1] = _1;
>   _2 = d;
>   _3 = c;
>   _4 = e;
>   _5 = b;
>   primal_bea_mpp (_2, _2, _2, _5, &flake, 0, _4, _3, _3, _2);
>   return;
> 
> }
> --------------------------------------
> These standard calls were used to dump this:
> 
>   FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node)
>   {
>     struct function *func = DECL_STRUCT_FUNCTION ( node->decl);
>     dump_function_header ( file, func->decl, (dump_flags_t)0);
>     dump_function_to_file ( func->decl, file, (dump_flags_t)0);
>   }
> 
> The GIMPLE above looks malformed to me. Is that the case
> or am I not grasping what's going on here?

What about it looks malformed to you?

The declaration of primal_bea_mpp and primal_net_simplex could probably
use some parameters, rather than being empty, which might make things
look more sane [1].  I think -Wstrict-prototypes will catch this.

Dave

[1] https://wiki.sei.cmu.edu/confluence/display/c/DCL20-C.+Explicitly+specify+void+when+a+function+accepts+no+arguments


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

* Re: Some really strange GIMPLE
  2021-04-27 20:10 Some really strange GIMPLE Gary Oblock
  2021-04-27 20:26 ` David Malcolm
@ 2021-04-27 23:17 ` Andrew Pinski
  2021-04-28  5:01   ` Aaron Gyes
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Pinski @ 2021-04-27 23:17 UTC (permalink / raw)
  To: Gary Oblock; +Cc: gcc

On Tue, Apr 27, 2021 at 3:51 PM Gary Oblock via Gcc <gcc@gcc.gnu.org> wrote:
>
> I'm chasing a bug and I used Creduce to produce a
> reduced test case. However, that's really beside to
> point.
>
> I this file:
> --------------------------------
> typedef struct basket {
> } a;
> long b;
> a *basket;
> int d, c, e;
> a *flake[2];
> void primal_bea_mpp();
> void primal_net_simplex() {
>   flake[1] = &basket[1];
>   primal_bea_mpp(d, d, d, b, flake, 0, e, c, c, d);
> }
> --------------------------------
> Produces this GIMPLE:
> ---------------------------------
> ;; Function primal_net_simplex (primal_net_simplex, funcdef_no=3, decl_uid=4447, cgraph_uid=16, symbol_order=41) (executed once)
>
> primal_net_simplex ()
> {
>   <bb 2> [local count: 1073741824]:
>   _1 = basket;
>   static struct a * flake[2];
> struct a *[2]
>   flake[1] = _1;
>   _2 = d;
>   _3 = c;
>   _4 = e;
>   _5 = b;
>   primal_bea_mpp (_2, _2, _2, _5, &flake, 0, _4, _3, _3, _2);
>   return;
>
> }
> --------------------------------------
> These standard calls were used to dump this:
>
>   FOR_EACH_FUNCTION_WITH_GIMPLE_BODY ( node)
>   {
>     struct function *func = DECL_STRUCT_FUNCTION ( node->decl);
>     dump_function_header ( file, func->decl, (dump_flags_t)0);
>     dump_function_to_file ( func->decl, file, (dump_flags_t)0);
>   }
>
> The GIMPLE above looks malformed to me. Is that the case
> or am I not grasping what's going on here?

The above gimple looks correct.
_1 should be of type a*. _2, _3, _4, and _5 are of type int.
Reading from globals (non-local) requires an assignment which is why
you get _1, _2, _3, _4, and _5.
There have already been optimizations going on before your pass so the
loads from d and c have been only done once.
&flake is considered a constant during the execution of the function
is it is propagated into the function call.

What is the exact thing you think is incorrect about the gimple here?

Thanks,
Andrew


>
> Note, I wouldn't be asking this question if this wasn't at the start of
> my pass and looking at stuff I hadn't modified.
>
> Thanks,
>
> Gary
>
>
> CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and contains information that is confidential and proprietary to Ampere Computing or its subsidiaries. It is to be used solely for the purpose of furthering the parties' business relationship. Any unauthorized review, copying, or distribution of this email (or any attachments thereto) is strictly prohibited. If you are not the intended recipient, please contact the sender immediately and permanently delete the original and any copies of this email and any attachments thereto.

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

* Re: Some really strange GIMPLE
  2021-04-27 23:17 ` Andrew Pinski
@ 2021-04-28  5:01   ` Aaron Gyes
  0 siblings, 0 replies; 4+ messages in thread
From: Aaron Gyes @ 2021-04-28  5:01 UTC (permalink / raw)
  To: gcc

> CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and contains information that is confidential and proprietary to Ampere Computing or its subsidiaries. It is to be used solely for the purpose of furthering the parties' business relationship. Any unauthorized review, copying, or distribution of this email (or any attachments thereto) is strictly prohibited. If you are not the intended recipient, please contact the sender immediately and permanently delete the original and any copies of this email and any attachments thereto.

This confidential message is going to be archived on the Internet publicly, likely forever. I would not send proprietary information to a public mailing list.

Aaron

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

end of thread, other threads:[~2021-04-28  5:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-27 20:10 Some really strange GIMPLE Gary Oblock
2021-04-27 20:26 ` David Malcolm
2021-04-27 23:17 ` Andrew Pinski
2021-04-28  5:01   ` Aaron Gyes

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