[llvm] [PredicateInfo] Support existing `PredicateType` by adding `PredicatePHI` when needing introduction of phi nodes (PR #151132)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 19 08:13:49 PDT 2025
================
@@ -0,0 +1,43 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -passes=print-predicateinfo < %s 2>&1 >/dev/null | FileCheck %s
+
+ at p = local_unnamed_addr global i32 0
+
+define noundef i32 @h5diff(i32 %0, i1 %1) local_unnamed_addr #0 {
+; CHECK-LABEL: @h5diff(
+; CHECK-NEXT: [[COND:%.*]] = icmp eq i32 [[TMP0:%.*]], 0
+; CHECK-NEXT: br i1 [[TMP1:%.*]], label [[TMP3:%.*]], label [[TMP4:%.*]]
+; CHECK: 3:
+; CHECK-NEXT: store i32 1, ptr @p, align 4
+; CHECK: [[DOT0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[TMP0]])
+; CHECK-NEXT: br i1 [[COND]], label [[TMP5:%.*]], label [[COMMON_RET:%.*]]
+; CHECK: common.ret:
+; CHECK-NEXT: ret i32 0
+; CHECK: 4:
+; CHECK-NEXT: store i32 2, ptr @p, align 4
+; CHECK: [[DOT1:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[TMP0]])
+; CHECK-NEXT: br i1 [[COND]], label [[TMP5]], label [[COMMON_RET]]
+; CHECK: 5:
+; CHECK-NEXT: [[DOTPREDICATE_PHI:%.*]] = phi i32 [ [[DOT1]], [[TMP4]] ], [ [[DOT0]], [[TMP3]] ]
+; CHECK: [[TMP6:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[TMP0]])
----------------
nikic wrote:
I think it makes sense to record the inserted phi nodes so that transforms can later remove them again (they currently remove the bitcasts and should remove the phis as well). But I think that should happen by just tracking them in a vector. I really don't see how representing them as PredicatePHI makes sense, as they do not in fact introduce a new predicate.
https://github.com/llvm/llvm-project/pull/151132
More information about the llvm-commits
mailing list