[llvm] 9007d0e - [UnifyLoopExits] Use poison instead of undef as placeholder [NFC]
Nuno Lopes via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 22 14:38:18 PDT 2023
Author: Nuno Lopes
Date: 2023-07-22T22:38:10+01:00
New Revision: 9007d0e0b6456424d81c89cf78ca9a3b01a61fed
URL: https://github.com/llvm/llvm-project/commit/9007d0e0b6456424d81c89cf78ca9a3b01a61fed
DIFF: https://github.com/llvm/llvm-project/commit/9007d0e0b6456424d81c89cf78ca9a3b01a61fed.diff
LOG: [UnifyLoopExits] Use poison instead of undef as placeholder [NFC]
This pass creates phi nodes where only one of the incoming values is used.
The remaining ones can be poison.
Added:
Modified:
llvm/lib/Transforms/Utils/UnifyLoopExits.cpp
llvm/test/Transforms/UnifyLoopExits/restore-ssa.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/UnifyLoopExits.cpp b/llvm/lib/Transforms/Utils/UnifyLoopExits.cpp
index fe62aee6526557..8c781f59ff5a4b 100644
--- a/llvm/lib/Transforms/Utils/UnifyLoopExits.cpp
+++ b/llvm/lib/Transforms/Utils/UnifyLoopExits.cpp
@@ -130,7 +130,7 @@ static void restoreSSA(const DominatorTree &DT, const Loop *L,
NewPhi->addIncoming(Def, In);
} else {
LLVM_DEBUG(dbgs() << "not dominated\n");
- NewPhi->addIncoming(UndefValue::get(Def->getType()), In);
+ NewPhi->addIncoming(PoisonValue::get(Def->getType()), In);
}
}
diff --git a/llvm/test/Transforms/UnifyLoopExits/restore-ssa.ll b/llvm/test/Transforms/UnifyLoopExits/restore-ssa.ll
index 09ff1a0a104616..16db74aba4674b 100644
--- a/llvm/test/Transforms/UnifyLoopExits/restore-ssa.ll
+++ b/llvm/test/Transforms/UnifyLoopExits/restore-ssa.ll
@@ -30,7 +30,7 @@ define i32 @exiting-used-in-exit(ptr %arg1, ptr %arg2) local_unnamed_addr align
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[INC]], [[C:%.*]] ], [ [[PHI_MOVED:%.*]], [[LOOP_EXIT_GUARD]] ]
; CHECK-NEXT: ret i32 [[PHI]]
; CHECK: loop.exit.guard:
-; CHECK-NEXT: [[MYTMP41_MOVED]] = phi i32 [ undef, [[A]] ], [ [[MYTMP41]], [[B]] ]
+; CHECK-NEXT: [[MYTMP41_MOVED]] = phi i32 [ poison, [[A]] ], [ [[MYTMP41]], [[B]] ]
; CHECK-NEXT: [[PHI_MOVED]] = phi i32 [ [[MYTMP42]], [[A]] ], [ undef, [[B]] ]
; CHECK-NEXT: [[GUARD_RETURN:%.*]] = phi i1 [ true, [[A]] ], [ false, [[B]] ]
; CHECK-NEXT: br i1 [[GUARD_RETURN]], label [[RETURN]], label [[C]]
@@ -84,7 +84,7 @@ define i32 @internal-used-in-exit(ptr %arg1, ptr %arg2) local_unnamed_addr align
; CHECK: return:
; CHECK-NEXT: ret i32 0
; CHECK: loop.exit.guard:
-; CHECK-NEXT: [[MYTMP41_MOVED]] = phi i32 [ undef, [[A]] ], [ [[MYTMP41]], [[C]] ]
+; CHECK-NEXT: [[MYTMP41_MOVED]] = phi i32 [ poison, [[A]] ], [ [[MYTMP41]], [[C]] ]
; CHECK-NEXT: [[GUARD_RETURN:%.*]] = phi i1 [ true, [[A]] ], [ false, [[C]] ]
; CHECK-NEXT: br i1 [[GUARD_RETURN]], label [[RETURN]], label [[D:%.*]]
;
@@ -141,7 +141,7 @@ define i32 @mixed-use-in-exit(ptr %arg1, ptr %arg2) local_unnamed_addr align 2 {
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[MYTMP41_MOVED:%.*]], [[D:%.*]] ], [ [[MYTMP42]], [[ENTRY:%.*]] ], [ [[PHI_MOVED:%.*]], [[LOOP_EXIT_GUARD]] ]
; CHECK-NEXT: ret i32 [[PHI]]
; CHECK: loop.exit.guard:
-; CHECK-NEXT: [[MYTMP41_MOVED]] = phi i32 [ undef, [[A]] ], [ [[MYTMP41]], [[C]] ]
+; CHECK-NEXT: [[MYTMP41_MOVED]] = phi i32 [ poison, [[A]] ], [ [[MYTMP41]], [[C]] ]
; CHECK-NEXT: [[PHI_MOVED]] = phi i32 [ [[MYTMP43]], [[A]] ], [ undef, [[C]] ]
; CHECK-NEXT: [[GUARD_RETURN:%.*]] = phi i1 [ true, [[A]] ], [ false, [[C]] ]
; CHECK-NEXT: br i1 [[GUARD_RETURN]], label [[RETURN]], label [[D]]
@@ -206,7 +206,7 @@ define i32 @phi-via-external-block(ptr %arg1, ptr %arg2) local_unnamed_addr alig
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[MYTMP41_MOVED:%.*]], [[D:%.*]] ], [ [[MYTMP42]], [[E:%.*]] ]
; CHECK-NEXT: ret i32 [[PHI]]
; CHECK: loop.exit.guard:
-; CHECK-NEXT: [[MYTMP41_MOVED]] = phi i32 [ undef, [[A]] ], [ [[MYTMP41]], [[C]] ]
+; CHECK-NEXT: [[MYTMP41_MOVED]] = phi i32 [ poison, [[A]] ], [ [[MYTMP41]], [[C]] ]
; CHECK-NEXT: [[GUARD_E:%.*]] = phi i1 [ true, [[A]] ], [ false, [[C]] ]
; CHECK-NEXT: br i1 [[GUARD_E]], label [[E]], label [[D]]
;
More information about the llvm-commits
mailing list