c/104002 - shufflevector variable indexing

Message ID 99p4058-7255-5195-o3nq-s5555p6rq3o@fhfr.qr
State New
Headers
Series c/104002 - shufflevector variable indexing |

Commit Message

Richard Biener Jan. 13, 2022, 2:12 p.m. UTC
  Variable indexing of a __builtin_shufflevector result is broken because
we fail to properly mark the TARGET_EXPR decl as addressable.

Bootstrapped and tested on x86_64-unknown-linux-gnu, OK?

Thanks,
Richard.

2022-01-13  Richard Biener  <rguenther@suse.de>

	PR c/104002
gcc/c-family/
	* c-common.c (c_common_mark_addressable_vec): Handle TARGET_EXPR.

gcc/testsuite/
	* c-c++-common/builtin-shufflevector-3.c: Move ...
	* c-c++-common/torture/builtin-shufflevector-3.c: ... here.
---
 gcc/c-family/c-common.c                                      | 5 ++++-
 .../c-c++-common/{ => torture}/builtin-shufflevector-3.c     | 0
 2 files changed, 4 insertions(+), 1 deletion(-)
 rename gcc/testsuite/c-c++-common/{ => torture}/builtin-shufflevector-3.c (100%)
  

Comments

Jakub Jelinek Jan. 13, 2022, 2:32 p.m. UTC | #1
On Thu, Jan 13, 2022 at 03:12:03PM +0100, Richard Biener wrote:
> Variable indexing of a __builtin_shufflevector result is broken because
> we fail to properly mark the TARGET_EXPR decl as addressable.
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu, OK?
> 
> Thanks,
> Richard.
> 
> 2022-01-13  Richard Biener  <rguenther@suse.de>
> 
> 	PR c/104002
> gcc/c-family/
> 	* c-common.c (c_common_mark_addressable_vec): Handle TARGET_EXPR.
> 
> gcc/testsuite/
> 	* c-c++-common/builtin-shufflevector-3.c: Move ...
> 	* c-c++-common/torture/builtin-shufflevector-3.c: ... here.

LGTM.

	Jakub
  

Patch

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 4a6a4edb763..a34f32f51a4 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -6989,12 +6989,15 @@  c_common_mark_addressable_vec (tree t)
     }
   if (!VAR_P (t)
       && TREE_CODE (t) != PARM_DECL
-      && TREE_CODE (t) != COMPOUND_LITERAL_EXPR)
+      && TREE_CODE (t) != COMPOUND_LITERAL_EXPR
+      && TREE_CODE (t) != TARGET_EXPR)
     return;
   if (!VAR_P (t) || !DECL_HARD_REGISTER (t))
     TREE_ADDRESSABLE (t) = 1;
   if (TREE_CODE (t) == COMPOUND_LITERAL_EXPR)
     TREE_ADDRESSABLE (COMPOUND_LITERAL_EXPR_DECL (t)) = 1;
+  else if (TREE_CODE (t) == TARGET_EXPR)
+    TREE_ADDRESSABLE (TARGET_EXPR_SLOT (t)) = 1;
 }
 
 
diff --git a/gcc/testsuite/c-c++-common/builtin-shufflevector-3.c b/gcc/testsuite/c-c++-common/torture/builtin-shufflevector-3.c
similarity index 100%
rename from gcc/testsuite/c-c++-common/builtin-shufflevector-3.c
rename to gcc/testsuite/c-c++-common/torture/builtin-shufflevector-3.c