[llvm] [PredicateInfo] Support existing `PredicateType` by adding `PredicatePHI` when needing introduction of phi nodes (PR #151132)
Rajveer Singh Bharadwaj via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 15 03:42:15 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]])
----------------
Rajveer100 wrote:
The primary circumstance I can think of is that it helps us differentiate from normal phis that already exist in the IR and are meant primarily for functionality purposes for the accurate output.
We don't want some random phi values that possibly could be from predicate info interfere. If it does, debugging would be much easier. You could already tell in tests it's quite distinguished.
https://github.com/llvm/llvm-project/pull/151132
More information about the llvm-commits
mailing list