
We can only replace phi(X, undef) with X, if X is known not to be poison. Otherwise, the result may be more poisonous on the undef branch. Fixes https://github.com/llvm/llvm-project/issues/68683.
24 lines
695 B
LLVM
24 lines
695 B
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
|
|
; RUN: opt < %s -passes=mem2reg -S | FileCheck %s
|
|
|
|
define i32 @testfunc(i1 %C, i32 %i, i8 %j) {
|
|
; CHECK-LABEL: define i32 @testfunc(
|
|
; CHECK-SAME: i1 [[C:%.*]], i32 [[I:%.*]], i8 [[J:%.*]]) {
|
|
; CHECK-NEXT: br i1 [[C]], label %[[T:.*]], label %[[CONT:.*]]
|
|
; CHECK: [[T]]:
|
|
; CHECK-NEXT: br label %[[CONT]]
|
|
; CHECK: [[CONT]]:
|
|
; CHECK-NEXT: [[I_0:%.*]] = phi i32 [ [[I]], %[[T]] ], [ undef, [[TMP0:%.*]] ]
|
|
; CHECK-NEXT: ret i32 [[I_0]]
|
|
;
|
|
%I = alloca i32
|
|
br i1 %C, label %T, label %Cont
|
|
T:
|
|
store i32 %i, ptr %I
|
|
br label %Cont
|
|
Cont:
|
|
%Y = load i32, ptr %I
|
|
ret i32 %Y
|
|
}
|
|
|