[llvm] test: check const-fold-gep with poison, undef, id (PR #125573)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 3 12:28:19 PST 2025


https://github.com/artagnon created https://github.com/llvm/llvm-project/pull/125573

For completeness, check poison, undef, and identity folding with GEP.

>From 7c9a5e380c8af99bd09c9258d178f89230dd73e3 Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <ramkumar.ramachandra at codasip.com>
Date: Mon, 3 Feb 2025 20:11:14 +0000
Subject: [PATCH] test: check const-fold-gep with poison, undef, id

For completeness, check poison, undef, and identity folding with GEP.
---
 llvm/test/Other/constant-fold-gep.ll | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/llvm/test/Other/constant-fold-gep.ll b/llvm/test/Other/constant-fold-gep.ll
index a4c55c62840a6c7..a9f4307fcd39dfb 100644
--- a/llvm/test/Other/constant-fold-gep.ll
+++ b/llvm/test/Other/constant-fold-gep.ll
@@ -24,18 +24,27 @@
 ; PLAIN: @F1 = global ptr getelementptr (i1, ptr inttoptr (i32 1 to ptr), i32 -2)
 ; PLAIN: @H8 = global ptr getelementptr (i8, ptr null, i32 -1)
 ; PLAIN: @H1 = global ptr getelementptr (i1, ptr null, i32 -1)
+; PLAIN: @U8 = global ptr undef
+; PLAIN: @P8 = global ptr poison
+; PLAIN: @Z8 = global ptr inttoptr (i32 1 to ptr)
 ; OPT: @G8 = local_unnamed_addr global ptr null
 ; OPT: @G1 = local_unnamed_addr global ptr null
 ; OPT: @F8 = local_unnamed_addr global ptr inttoptr (i64 -1 to ptr)
 ; OPT: @F1 = local_unnamed_addr global ptr inttoptr (i64 -1 to ptr)
 ; OPT: @H8 = local_unnamed_addr global ptr inttoptr (i64 -1 to ptr)
 ; OPT: @H1 = local_unnamed_addr global ptr inttoptr (i64 -1 to ptr)
+; OPT: @U8 = local_unnamed_addr global ptr undef
+; OPT: @P8 = local_unnamed_addr global ptr poison
+; OPT: @Z8 = local_unnamed_addr global ptr inttoptr (i32 1 to ptr)
 ; TO: @G8 = local_unnamed_addr global ptr null
 ; TO: @G1 = local_unnamed_addr global ptr null
 ; TO: @F8 = local_unnamed_addr global ptr inttoptr (i64 -1 to ptr)
 ; TO: @F1 = local_unnamed_addr global ptr inttoptr (i64 -1 to ptr)
 ; TO: @H8 = local_unnamed_addr global ptr inttoptr (i64 -1 to ptr)
 ; TO: @H1 = local_unnamed_addr global ptr inttoptr (i64 -1 to ptr)
+; TO: @U8 = local_unnamed_addr global ptr undef
+; TO: @P8 = local_unnamed_addr global ptr poison
+; TO: @Z8 = local_unnamed_addr global ptr inttoptr (i32 1 to ptr)
 
 @G8 = global ptr getelementptr (i8, ptr inttoptr (i32 1 to ptr), i32 -1)
 @G1 = global ptr getelementptr (i1, ptr inttoptr (i32 1 to ptr), i32 -1)
@@ -43,6 +52,9 @@
 @F1 = global ptr getelementptr (i1, ptr inttoptr (i32 1 to ptr), i32 -2)
 @H8 = global ptr getelementptr (i8, ptr inttoptr (i32 0 to ptr), i32 -1)
 @H1 = global ptr getelementptr (i1, ptr inttoptr (i32 0 to ptr), i32 -1)
+ at U8 = global ptr getelementptr (i8, ptr undef, i32 -1)
+ at P8 = global ptr getelementptr (i8, ptr poison, i32 -1)
+ at Z8 = global ptr getelementptr (i8, ptr inttoptr (i32 1 to ptr), i32 0)
 
 ; The target-independent folder should be able to do some clever
 ; simplifications on sizeof, alignof, and offsetof expressions. The



More information about the llvm-commits mailing list