Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions llvm/test/Transforms/Util/PredicateInfo/branch-on-same-cond.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-inst-comments
; RUN: opt -S -passes=print-predicateinfo < %s 2>&1 >/dev/null | FileCheck %s

; FIXME: RenamedOp should be %cmp or %x in all cases here,
Expand All @@ -9,24 +9,24 @@ define i32 @test(i32 %x) {
; CHECK-NEXT: br label [[BB1:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X:%.*]], 0
; CHECK: RenamedOp: [[CMP]]
; CHECK: [[CMP_0:%.*]] = bitcast i1 [[CMP]] to i1
; CHECK: RenamedOp: [[X]]
; CHECK: [[X_0:%.*]] = bitcast i32 [[X]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = icmp eq i32 [[X]], 0 Edge: [label [[BB1]],label %bb2], RenamedOp: [[CMP]] }
; CHECK-NEXT: [[CMP_0:%.*]] = bitcast i1 [[CMP]] to i1
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = icmp eq i32 [[X]], 0 Edge: [label [[BB1]],label %bb2], RenamedOp: [[X]] }
; CHECK-NEXT: [[X_0:%.*]] = bitcast i32 [[X]] to i32
; CHECK-NEXT: br i1 [[CMP]], label [[BB2:%.*]], label [[EXIT1:%.*]]
; CHECK: bb2:
; CHECK: RenamedOp: [[CMP_0]]
; CHECK: [[CMP_0_1:%.*]] = bitcast i1 [[CMP_0]] to i1
; CHECK: RenamedOp: [[X]]
; CHECK: [[X_0_1:%.*]] = bitcast i32 [[X_0]] to i32
; CHECK: RenamedOp: [[X_0]]
; CHECK: [[X_0_4:%.*]] = bitcast i32 [[X_0]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = icmp eq i32 [[X]], 0 Edge: [label [[BB2]],label %bb3], RenamedOp: [[CMP_0]] }
; CHECK-NEXT: [[CMP_0_1:%.*]] = bitcast i1 [[CMP_0]] to i1
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = icmp eq i32 [[X]], 0 Edge: [label [[BB2]],label %bb3], RenamedOp: [[X]] }
; CHECK-NEXT: [[X_0_1:%.*]] = bitcast i32 [[X_0]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 0 Comparison: [[CMP]] = icmp eq i32 [[X]], 0 Edge: [label [[BB2]],label %exit2], RenamedOp: [[X_0]] }
; CHECK-NEXT: [[X_0_4:%.*]] = bitcast i32 [[X_0]] to i32
; CHECK-NEXT: br i1 [[CMP_0]], label [[BB3:%.*]], label [[EXIT2:%.*]]
; CHECK: bb3:
; CHECK: RenamedOp: [[X]]
; CHECK: [[X_0_1_2:%.*]] = bitcast i32 [[X_0_1]] to i32
; CHECK: RenamedOp: [[X_0_1]]
; CHECK: [[X_0_1_3:%.*]] = bitcast i32 [[X_0_1]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = icmp eq i32 [[X]], 0 Edge: [label [[BB3]],label %exit3], RenamedOp: [[X]] }
; CHECK-NEXT: [[X_0_1_2:%.*]] = bitcast i32 [[X_0_1]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 0 Comparison: [[CMP]] = icmp eq i32 [[X]], 0 Edge: [label [[BB3]],label %exit4], RenamedOp: [[X_0_1]] }
; CHECK-NEXT: [[X_0_1_3:%.*]] = bitcast i32 [[X_0_1]] to i32
; CHECK-NEXT: br i1 [[CMP_0_1]], label [[EXIT3:%.*]], label [[EXIT4:%.*]]
; CHECK: exit1:
; CHECK-NEXT: ret i32 0
Expand Down
83 changes: 55 additions & 28 deletions llvm/test/Transforms/Util/PredicateInfo/condprop.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-inst-comments
; RUN: opt -passes=print-predicateinfo -disable-output < %s 2>&1 | FileCheck %s

@a = external global i32 ; <ptr> [#uses=7]
Expand Down Expand Up @@ -98,11 +98,16 @@ define void @test3(i32 %x, i32 %y) {
; CHECK-NEXT: [[XZ:%.*]] = icmp eq i32 [[X:%.*]], 0
; CHECK-NEXT: [[YZ:%.*]] = icmp eq i32 [[Y:%.*]], 0
; CHECK-NEXT: [[Z:%.*]] = and i1 [[XZ]], [[YZ]]
; CHECK: [[Z_0:%.*]] = bitcast i1 [[Z]] to i1
; CHECK: [[XZ_0:%.*]] = bitcast i1 [[XZ]] to i1
; CHECK: [[X_0:%.*]] = bitcast i32 [[X]] to i32
; CHECK: [[YZ_0:%.*]] = bitcast i1 [[YZ]] to i1
; CHECK: [[Y_0:%.*]] = bitcast i32 [[Y]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 0 Comparison: [[Z]] = and i1 [[XZ]], [[YZ]] Edge: [label [[TMP0:%.*]],label %nope], RenamedOp: [[Z]] }
Copy link
Contributor

Choose a reason for hiding this comment

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

Here one of the labels gets a wildcard and the other doesn't. I wonder whether printing a space after the comma would give use consistent behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder whether printing a space after the comma would give use consistent behavior?

@nikic, Unfortunately, it does not work :(.

It is another reason to cause such inconsistency.
image

Copy link
Contributor Author

@Camsyn Camsyn Oct 29, 2025

Choose a reason for hiding this comment

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

Maybe the wildcard is used to define [[TMP0]] when it first appears, and the following [[TMP0]]]s just reference the first definition, just like mermaid/dot grammar

Copy link
Member

Choose a reason for hiding this comment

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

I think these tests default to an old --version which doesn't use wildcards for labels. Could you try adding --version 6 to the start of the test?

Copy link
Contributor Author

@Camsyn Camsyn Oct 30, 2025

Choose a reason for hiding this comment

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

Maybe the wildcard is used to define [[TMP0]] when it first appears, and the following [[TMP0]]]s just reference the first definition, just like mermaid/dot grammar

I may have misunderstood earlier. If @nikic thinks that the label %nope in ... Edge: [label [[TMP0 :%.*]], label % nope],... is mistakenly missing a wildcard, I think I have found the cause, not a version issue or "a missed space after the comma".

It's the mismatched variable regex r"(\s*)(?:%([\w$.-]+?))([,\s\(\)\}]|\Z)" that causes such an issue:
image

TWO approaches to fix:

  1. Change PredicateInfo's printing
  2. Change the regex (maybe the regex is wrong? Why does it expect some character after a variable?)

Full regex:

(\s*)((?:%([\w$.-]+?))|(?:#([0-9]+))|^(?:attributes #([0-9]+))|(?:@([0-9]+))|^(?:@([0-9]+))|^(?:@([a-zA-Z0-9_$\"\\.-]*[a-zA-Z_$\"\\.-][a-zA-Z0-9_$\"\\.-]*))|(?:!dbg (![0-9]+))|(?:!DIAssignID (![0-9]+))|(?:!prof (![0-9]+))|(?:!tbaa (![0-9]+))|(?:!tbaa.struct (![0-9]+))|(?:!range (![0-9]+))|(?:!llvm.loop (![0-9]+))|^(?:(![0-9]+))|(?:!llvm.access.group (![0-9]+))|(?:![a-z.]+ (![0-9]+))|(?:[, (](![0-9]+)))([,\s\(\)\}]|\Z)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why that specific character requirement exists, but it would probably be fine to add \] to the list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

597ac47 introduced such var regex suffix to help locate a var.

I think it should be safe to add ']' as another suffix, since phi i32 [%a, %then], [%b, %else] without space is also a legal LLVM IR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nikic, do you think the suffix change should be gated by a version? This suffix change might lead to a negligible impact on the current test, as such a pattern of ... %var] is rare.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need a version for this.

; CHECK-NEXT: [[Z_0:%.*]] = bitcast i1 [[Z]] to i1
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[XZ]] = icmp eq i32 [[X]], 0 Edge: [label [[TMP0]],label %both_zero], RenamedOp: [[XZ]] }
; CHECK-NEXT: [[XZ_0:%.*]] = bitcast i1 [[XZ]] to i1
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[XZ]] = icmp eq i32 [[X]], 0 Edge: [label [[TMP0]],label %both_zero], RenamedOp: [[X]] }
; CHECK-NEXT: [[X_0:%.*]] = bitcast i32 [[X]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[YZ]] = icmp eq i32 [[Y]], 0 Edge: [label [[TMP0]],label %both_zero], RenamedOp: [[YZ]] }
; CHECK-NEXT: [[YZ_0:%.*]] = bitcast i1 [[YZ]] to i1
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[YZ]] = icmp eq i32 [[Y]], 0 Edge: [label [[TMP0]],label %both_zero], RenamedOp: [[Y]] }
; CHECK-NEXT: [[Y_0:%.*]] = bitcast i32 [[Y]] to i32
; CHECK-NEXT: br i1 [[Z]], label [[BOTH_ZERO:%.*]], label [[NOPE:%.*]]
; CHECK: both_zero:
; CHECK-NEXT: call void @foo(i1 [[XZ_0]])
Expand Down Expand Up @@ -133,7 +138,8 @@ define void @test4(i1 %b, i32 %x) {
; CHECK-LABEL: @test4(
; CHECK-NEXT: br i1 [[B:%.*]], label [[SW:%.*]], label [[CASE3:%.*]]
; CHECK: sw:
; CHECK: [[X_0:%.*]] = bitcast i32 [[X:%.*]] to i32
; CHECK-NEXT: ; switch predicate info { CaseValue: i32 1 Edge: [label [[SW]],label %case1], RenamedOp: [[X:%.*]] }
; CHECK-NEXT: [[X_0:%.*]] = bitcast i32 [[X]] to i32
; CHECK-NEXT: switch i32 [[X]], label [[DEFAULT:%.*]] [
; CHECK-NEXT: i32 0, label [[CASE0:%.*]]
; CHECK-NEXT: i32 1, label [[CASE1:%.*]]
Expand Down Expand Up @@ -180,10 +186,14 @@ case3:
define i1 @test5(i32 %x, i32 %y) {
; CHECK-LABEL: @test5(
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]
; CHECK: [[X_0:%.*]] = bitcast i32 [[X]] to i32
; CHECK: [[X_1:%.*]] = bitcast i32 [[X]] to i32
; CHECK: [[Y_0:%.*]] = bitcast i32 [[Y]] to i32
; CHECK: [[Y_1:%.*]] = bitcast i32 [[Y]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = icmp eq i32 [[X]], [[Y]] Edge: [label [[TMP0:%.*]],label %same], RenamedOp: [[X]] }
; CHECK-NEXT: [[X_0:%.*]] = bitcast i32 [[X]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 0 Comparison: [[CMP]] = icmp eq i32 [[X]], [[Y]] Edge: [label [[TMP0]],label %different], RenamedOp: [[X]] }
; CHECK-NEXT: [[X_1:%.*]] = bitcast i32 [[X]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = icmp eq i32 [[X]], [[Y]] Edge: [label [[TMP0]],label %same], RenamedOp: [[Y]] }
; CHECK-NEXT: [[Y_0:%.*]] = bitcast i32 [[Y]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 0 Comparison: [[CMP]] = icmp eq i32 [[X]], [[Y]] Edge: [label [[TMP0]],label %different], RenamedOp: [[Y]] }
; CHECK-NEXT: [[Y_1:%.*]] = bitcast i32 [[Y]] to i32
; CHECK-NEXT: br i1 [[CMP]], label [[SAME:%.*]], label [[DIFFERENT:%.*]]
; CHECK: same:
; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i32 [[X_0]], [[Y_0]]
Expand Down Expand Up @@ -253,10 +263,14 @@ different:
define i1 @test7(i32 %x, i32 %y) {
; CHECK-LABEL: @test7(
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]]
; CHECK: [[X_0:%.*]] = bitcast i32 [[X]] to i32
; CHECK: [[X_1:%.*]] = bitcast i32 [[X]] to i32
; CHECK: [[Y_0:%.*]] = bitcast i32 [[Y]] to i32
; CHECK: [[Y_1:%.*]] = bitcast i32 [[Y]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = icmp sgt i32 [[X]], [[Y]] Edge: [label [[TMP0:%.*]],label %same], RenamedOp: [[X]] }
; CHECK-NEXT: [[X_0:%.*]] = bitcast i32 [[X]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 0 Comparison: [[CMP]] = icmp sgt i32 [[X]], [[Y]] Edge: [label [[TMP0]],label %different], RenamedOp: [[X]] }
; CHECK-NEXT: [[X_1:%.*]] = bitcast i32 [[X]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = icmp sgt i32 [[X]], [[Y]] Edge: [label [[TMP0]],label %same], RenamedOp: [[Y]] }
; CHECK-NEXT: [[Y_0:%.*]] = bitcast i32 [[Y]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 0 Comparison: [[CMP]] = icmp sgt i32 [[X]], [[Y]] Edge: [label [[TMP0]],label %different], RenamedOp: [[Y]] }
; CHECK-NEXT: [[Y_1:%.*]] = bitcast i32 [[Y]] to i32
; CHECK-NEXT: br i1 [[CMP]], label [[SAME:%.*]], label [[DIFFERENT:%.*]]
; CHECK: same:
; CHECK-NEXT: [[CMP2:%.*]] = icmp sle i32 [[X_0]], [[Y_0]]
Expand All @@ -280,10 +294,14 @@ different:
define i1 @test7_fp(float %x, float %y) {
; CHECK-LABEL: @test7_fp(
; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt float [[X:%.*]], [[Y:%.*]]
; CHECK: [[X_0:%.*]] = bitcast float [[X]] to float
; CHECK: [[X_1:%.*]] = bitcast float [[X]] to float
; CHECK: [[Y_0:%.*]] = bitcast float [[Y]] to float
; CHECK: [[Y_1:%.*]] = bitcast float [[Y]] to float
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = fcmp ogt float [[X]], [[Y]] Edge: [label [[TMP0:%.*]],label %same], RenamedOp: [[X]] }
; CHECK-NEXT: [[X_0:%.*]] = bitcast float [[X]] to float
; CHECK-NEXT: ; branch predicate info { TrueEdge: 0 Comparison: [[CMP]] = fcmp ogt float [[X]], [[Y]] Edge: [label [[TMP0]],label %different], RenamedOp: [[X]] }
; CHECK-NEXT: [[X_1:%.*]] = bitcast float [[X]] to float
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = fcmp ogt float [[X]], [[Y]] Edge: [label [[TMP0]],label %same], RenamedOp: [[Y]] }
; CHECK-NEXT: [[Y_0:%.*]] = bitcast float [[Y]] to float
; CHECK-NEXT: ; branch predicate info { TrueEdge: 0 Comparison: [[CMP]] = fcmp ogt float [[X]], [[Y]] Edge: [label [[TMP0]],label %different], RenamedOp: [[Y]] }
; CHECK-NEXT: [[Y_1:%.*]] = bitcast float [[Y]] to float
; CHECK-NEXT: br i1 [[CMP]], label [[SAME:%.*]], label [[DIFFERENT:%.*]]
; CHECK: same:
; CHECK-NEXT: [[CMP2:%.*]] = fcmp ule float [[X_0]], [[Y_0]]
Expand Down Expand Up @@ -353,8 +371,10 @@ different:
define i32 @test9(i32 %i, i32 %j) {
; CHECK-LABEL: @test9(
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], [[J:%.*]]
; CHECK: [[I_0:%.*]] = bitcast i32 [[I]] to i32
; CHECK: [[J_0:%.*]] = bitcast i32 [[J]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = icmp eq i32 [[I]], [[J]] Edge: [label [[TMP0:%.*]],label %cond_true], RenamedOp: [[I]] }
; CHECK-NEXT: [[I_0:%.*]] = bitcast i32 [[I]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = icmp eq i32 [[I]], [[J]] Edge: [label [[TMP0]],label %cond_true], RenamedOp: [[J]] }
; CHECK-NEXT: [[J_0:%.*]] = bitcast i32 [[J]] to i32
; CHECK-NEXT: br i1 [[CMP]], label [[COND_TRUE:%.*]], label [[RET:%.*]]
; CHECK: cond_true:
; CHECK-NEXT: [[DIFF:%.*]] = sub i32 [[I_0]], [[J_0]]
Expand All @@ -376,8 +396,10 @@ ret:
define i32 @test10(i32 %j, i32 %i) {
; CHECK-LABEL: @test10(
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], [[J:%.*]]
; CHECK: [[I_0:%.*]] = bitcast i32 [[I]] to i32
; CHECK: [[J_0:%.*]] = bitcast i32 [[J]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = icmp eq i32 [[I]], [[J]] Edge: [label [[TMP0:%.*]],label %cond_true], RenamedOp: [[I]] }
; CHECK-NEXT: [[I_0:%.*]] = bitcast i32 [[I]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = icmp eq i32 [[I]], [[J]] Edge: [label [[TMP0]],label %cond_true], RenamedOp: [[J]] }
; CHECK-NEXT: [[J_0:%.*]] = bitcast i32 [[J]] to i32
; CHECK-NEXT: br i1 [[CMP]], label [[COND_TRUE:%.*]], label [[RET:%.*]]
; CHECK: cond_true:
; CHECK-NEXT: [[DIFF:%.*]] = sub i32 [[I_0]], [[J_0]]
Expand All @@ -403,14 +425,17 @@ define i32 @test11(i32 %x) {
; CHECK-NEXT: [[V0:%.*]] = call i32 @yogibar()
; CHECK-NEXT: [[V1:%.*]] = call i32 @yogibar()
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[V0]], [[V1]]
; CHECK: [[V0_0:%.*]] = bitcast i32 [[V0]] to i32
; CHECK: [[V1_0:%.*]] = bitcast i32 [[V1]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 0 Comparison: [[CMP]] = icmp eq i32 [[V0]], [[V1]] Edge: [label [[TMP0:%.*]],label %next], RenamedOp: [[V0]] }
; CHECK-NEXT: [[V0_0:%.*]] = bitcast i32 [[V0]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = icmp eq i32 [[V0]], [[V1]] Edge: [label [[TMP0]],label %cond_true], RenamedOp: [[V1]] }
; CHECK-NEXT: [[V1_0:%.*]] = bitcast i32 [[V1]] to i32
; CHECK-NEXT: br i1 [[CMP]], label [[COND_TRUE:%.*]], label [[NEXT:%.*]]
; CHECK: cond_true:
; CHECK-NEXT: ret i32 [[V1_0]]
; CHECK: next:
; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 [[X:%.*]], [[V0_0]]
; CHECK: [[V0_0_1:%.*]] = bitcast i32 [[V0_0]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP2]] = icmp eq i32 [[X]], [[V0_0]] Edge: [label [[NEXT]],label %cond_true2], RenamedOp: [[V0_0]] }
; CHECK-NEXT: [[V0_0_1:%.*]] = bitcast i32 [[V0_0]] to i32
; CHECK-NEXT: br i1 [[CMP2]], label [[COND_TRUE2:%.*]], label [[NEXT2:%.*]]
; CHECK: cond_true2:
; CHECK-NEXT: ret i32 [[V0_0_1]]
Expand Down Expand Up @@ -439,8 +464,10 @@ next2:
define i32 @test12(i32 %x) {
; CHECK-LABEL: @test12(
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X:%.*]], 0
; CHECK: [[X_0:%.*]] = bitcast i32 [[X]] to i32
; CHECK: [[X_1:%.*]] = bitcast i32 [[X]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = icmp eq i32 [[X]], 0 Edge: [label [[TMP0:%.*]],label %cond_true], RenamedOp: [[X]] }
; CHECK-NEXT: [[X_0:%.*]] = bitcast i32 [[X]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 0 Comparison: [[CMP]] = icmp eq i32 [[X]], 0 Edge: [label [[TMP0]],label %cond_false], RenamedOp: [[X]] }
; CHECK-NEXT: [[X_1:%.*]] = bitcast i32 [[X]] to i32
; CHECK-NEXT: br i1 [[CMP]], label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
; CHECK: cond_true:
; CHECK-NEXT: br label [[RET:%.*]]
Expand Down
16 changes: 10 additions & 6 deletions llvm/test/Transforms/Util/PredicateInfo/diamond.ll
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -passes=print-predicateinfo < %s 2>&1 | FileCheck %s
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-inst-comments
; RUN: opt -passes=print-predicateinfo -disable-output < %s 2>&1 | FileCheck %s
define i1 @f(i32 %x, i1 %y) {
; CHECK-LABEL: @f(
; CHECK-NEXT: br i1 [[Y:%.*]], label [[BB0:%.*]], label [[BB1:%.*]]
; CHECK: bb0:
; CHECK-NEXT: [[CMP:%.*]] = icmp sge i32 [[X:%.*]], 0
; CHECK: [[X_0:%.*]] = bitcast i32 [[X]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP]] = icmp sge i32 [[X]], 0 Edge: [label [[BB0]],label %bb2], RenamedOp: [[X]] }
; CHECK-NEXT: [[X_0:%.*]] = bitcast i32 [[X]] to i32
; CHECK-NEXT: br i1 [[CMP]], label [[BB2:%.*]], label [[BB3:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[X2:%.*]] = add nuw nsw i32 [[X]], 1
; CHECK-NEXT: [[CMP2:%.*]] = icmp sge i32 [[X2]], 2
; CHECK: [[X2_0:%.*]] = bitcast i32 [[X2]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 1 Comparison: [[CMP2]] = icmp sge i32 [[X2]], 2 Edge: [label [[BB1]],label %bb2], RenamedOp: [[X2]] }
; CHECK-NEXT: [[X2_0:%.*]] = bitcast i32 [[X2]] to i32
; CHECK-NEXT: br i1 [[CMP2]], label [[BB2]], label [[BB3]]
; CHECK: bb2:
; CHECK-NEXT: [[X3:%.*]] = phi i32 [ [[X_0]], [[BB0]] ], [ [[X2_0]], [[BB1]] ]
Expand Down Expand Up @@ -38,12 +40,14 @@ define i1 @g(i32 %x, i1 %y) {
; CHECK-NEXT: br i1 [[Y:%.*]], label [[BB0:%.*]], label [[BB1:%.*]]
; CHECK: bb0:
; CHECK-NEXT: [[CMP:%.*]] = icmp sge i32 [[X:%.*]], 0
; CHECK: [[X_0:%.*]] = bitcast i32 [[X]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 0 Comparison: [[CMP]] = icmp sge i32 [[X]], 0 Edge: [label [[BB0]],label %bb2], RenamedOp: [[X]] }
; CHECK-NEXT: [[X_0:%.*]] = bitcast i32 [[X]] to i32
; CHECK-NEXT: br i1 [[CMP]], label [[BB3:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[X2:%.*]] = add nuw nsw i32 [[X]], 1
; CHECK-NEXT: [[CMP2:%.*]] = icmp sge i32 [[X2]], 2
; CHECK: [[X2_0:%.*]] = bitcast i32 [[X2]] to i32
; CHECK-NEXT: ; branch predicate info { TrueEdge: 0 Comparison: [[CMP2]] = icmp sge i32 [[X2]], 2 Edge: [label [[BB1]],label %bb2], RenamedOp: [[X2]] }
; CHECK-NEXT: [[X2_0:%.*]] = bitcast i32 [[X2]] to i32
; CHECK-NEXT: br i1 [[CMP2]], label [[BB3]], label [[BB2]]
; CHECK: bb2:
; CHECK-NEXT: [[X3:%.*]] = phi i32 [ [[X_0]], [[BB0]] ], [ [[X2_0]], [[BB1]] ]
Expand Down
Loading