Skip to content

IndVarSimplify: improve a test, stripping undef #126069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 6, 2025

Conversation

artagnon
Copy link
Contributor

@artagnon artagnon commented Feb 6, 2025

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Feb 6, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Ramkumar Ramachandra (artagnon)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/126069.diff

1 Files Affected:

  • (modified) llvm/test/Transforms/IndVarSimplify/rewrite-loop-exit-values-phi.ll (+7-7)
diff --git a/llvm/test/Transforms/IndVarSimplify/rewrite-loop-exit-values-phi.ll b/llvm/test/Transforms/IndVarSimplify/rewrite-loop-exit-values-phi.ll
index 37bc67c23adb756..02901b913bc0433 100644
--- a/llvm/test/Transforms/IndVarSimplify/rewrite-loop-exit-values-phi.ll
+++ b/llvm/test/Transforms/IndVarSimplify/rewrite-loop-exit-values-phi.ll
@@ -13,12 +13,12 @@ target triple = "x86_64-unknown-linux-gnu"
 define dso_local void @hoge() local_unnamed_addr {
 ; CHECK-LABEL: @hoge(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[N:%.*]] = sdiv exact i64 undef, 40
-; CHECK-NEXT:    [[TMP0:%.*]] = sub i64 undef, [[N]]
+; CHECK-NEXT:    [[N:%.*]] = sdiv exact i64 poison, 40
+; CHECK-NEXT:    [[TMP0:%.*]] = sub i64 poison, [[N]]
 ; CHECK-NEXT:    br label [[HEADER:%.*]]
 ; CHECK:       header:
 ; CHECK-NEXT:    [[INDVARS_IV:%.*]] = phi i64 [ [[INDVARS_IV_NEXT:%.*]], [[LATCH:%.*]] ], [ [[TMP0]], [[ENTRY:%.*]] ]
-; CHECK-NEXT:    [[IDX:%.*]] = phi i64 [ [[IDX_NEXT:%.*]], [[LATCH]] ], [ undef, [[ENTRY]] ]
+; CHECK-NEXT:    [[IDX:%.*]] = phi i64 [ [[IDX_NEXT:%.*]], [[LATCH]] ], [ poison, [[ENTRY]] ]
 ; CHECK-NEXT:    [[COND:%.*]] = icmp sgt i64 [[N]], [[IDX]]
 ; CHECK-NEXT:    br i1 [[COND]], label [[END:%.*]], label [[INNER_PREHEADER:%.*]]
 ; CHECK:       inner.preheader:
@@ -26,7 +26,7 @@ define dso_local void @hoge() local_unnamed_addr {
 ; CHECK:       inner:
 ; CHECK-NEXT:    [[I:%.*]] = phi i64 [ [[I_NEXT:%.*]], [[INNER]] ], [ 0, [[INNER_PREHEADER]] ]
 ; CHECK-NEXT:    [[I_NEXT]] = add nuw i64 [[I]], 1
-; CHECK-NEXT:    store i64 undef, ptr @ptr, align 8
+; CHECK-NEXT:    store i64 poison, ptr @ptr, align 8
 ; CHECK-NEXT:    [[EXITCOND:%.*]] = icmp ne i64 [[I_NEXT]], [[INDVARS_IV]]
 ; CHECK-NEXT:    br i1 [[EXITCOND]], label [[INNER]], label [[INNER_EXIT:%.*]]
 ; CHECK:       inner_exit:
@@ -41,11 +41,11 @@ define dso_local void @hoge() local_unnamed_addr {
 ; CHECK-NEXT:    ret void
 ;
 entry:                                            ; preds = %entry
-  %n = sdiv exact i64 undef, 40
+  %n = sdiv exact i64 poison, 40
   br label %header
 
 header:                                           ; preds = %latch, %entry
-  %idx = phi i64 [ %idx.next, %latch ], [ undef, %entry ]
+  %idx = phi i64 [ %idx.next, %latch ], [ poison, %entry ]
   %cond = icmp sgt i64 %n, %idx
   br i1 %cond, label %end, label %inner
 
@@ -54,7 +54,7 @@ inner:                                            ; preds = %inner, %header
   %j = phi i64 [ %j.next, %inner ], [ %n, %header ]
   %i.next = add nsw i64 %i, 1
   %j.next = add nsw i64 %j, 1
-  store i64 undef, ptr @ptr
+  store i64 poison, ptr @ptr
   %cond1 = icmp slt i64 %j, %idx
   br i1 %cond1, label %inner, label %inner_exit
 

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, please replace these with non-undef/poison values instead. The store can be 0 and the sdiv operand should be an argument.

@artagnon artagnon changed the title IndVarSimplify/test: replace undef with poison IndVarSimplify: improve a test, stripping undef Feb 6, 2025
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@artagnon artagnon merged commit 34624d8 into llvm:main Feb 6, 2025
6 of 8 checks passed
@artagnon artagnon deleted the ivs-test-undef branch February 6, 2025 18:10
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants