Patchwork [PR44503] Fixes "control flow in the middle of basic block" with -fprefetch-loop-arrays

login
register
mail settings
Submitter Fang, Changpeng
Date June 16, 2010, 12:27 a.m.
Message ID <D4C76825A6780047854A11E93CDE84D02F7746@SAUSEXMBP01.amd.com>
Download mbox | patch
Permalink /patch/55828/
State New
Headers show

Comments

Fang, Changpeng - June 16, 2010, 12:27 a.m.
>this does not make much sense to me; why should there be no natural loops?  Edges in CFG (conservatively)
>correctly describe the control flow, so the loops may be detected as usual.  The correct fix is to
>ensure that is_ctrl_altering_stmt does not return true for_builtin_prefetch,

You are right. We should address the problem exposed by _builtin_prefetch in this patch.
Attached is the patch that thinks _builtin_prefetch does not change the control flow.

Is this OK to commit?

Thanks,

Changpeng
Zdenek Dvorak - June 16, 2010, 3:48 a.m.
Hi,

> >this does not make much sense to me; why should there be no natural loops?  Edges in CFG (conservatively)
> >correctly describe the control flow, so the loops may be detected as usual.  The correct fix is to
> >ensure that is_ctrl_altering_stmt does not return true for_builtin_prefetch,
> 
> You are right. We should address the problem exposed by _builtin_prefetch in this patch.
> Attached is the patch that thinks _builtin_prefetch does not change the control flow.

while a more comprehensive solution (as suggested by Honza) would be better long-term,
for now this seems ok to me (but I cannot approve it),

Zdenek

Patch

From a5ee46bc858991c3ebe1abac680e0fe862dc98a1 Mon Sep 17 00:00:00 2001
From: Changpeng Fang <chfang@pathscale.(none)>
Date: Tue, 15 Jun 2010 14:34:09 -0700
Subject: [PATCH] pr44503 builtin_prefetch does not change control flow

	*gcc/tree-cfg.c (is_ctrl_altering_stmt): Return false if
	the gimple_call is _builtin_prefetch.
---
 gcc/tree-cfg.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index eca3ed0..76b7f56 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -2259,6 +2259,10 @@  is_ctrl_altering_stmt (gimple t)
       {
 	int flags = gimple_call_flags (t);
 
+        /* BUILT_IN_PREFETCH would never alter the control flow.  */  
+	if (gimple_call_builtin_p (t, BUILT_IN_PREFETCH))
+	  return false;
+
 	/* A non-pure/const call alters flow control if the current
 	   function has nonlocal labels.  */
 	if (!(flags & (ECF_CONST | ECF_PURE)) && cfun->has_nonlocal_label)
-- 
1.6.3.3