Skip to content

Commit 5608bdc

Browse files
committed
Follow the review
1 parent 4835c17 commit 5608bdc

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

llvm/lib/Transforms/Utils/PredicateInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ bool PredicateInfoBuilder::stackIsInScope(const ValueDFSStack &Stack,
260260
// next to the defs they must go with so that we can know it's time to pop
261261
// the stack when we hit the end of the phi uses for a given def.
262262
const ValueDFS &Top = *Stack.back().V;
263-
if (Top.LocalNum == LN_Last && Top.PInfo) {
263+
assert(Top.PInfo && "RenameStack should only contain predicate infos (defs)");
264+
if (Top.LocalNum == LN_Last) {
264265
if (!VDUse.U) {
265266
assert(VDUse.PInfo && "A non-use VDUse should have a predicate info");
266267
// We should reserve adjacent LN_Last defs for the same phi use.

llvm/test/Transforms/SCCP/conditions-ranges.ll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,3 +1547,28 @@ bb2:
15471547
call void @use(i1 %c4)
15481548
ret void
15491549
}
1550+
1551+
define i1 @and_predicate_dominating_phi(i32 %x) {
1552+
; CHECK-LABEL: @and_predicate_dominating_phi(
1553+
; CHECK-NEXT: entry:
1554+
; CHECK-NEXT: [[XGE1:%.*]] = icmp uge i32 [[X:%.*]], 1
1555+
; CHECK-NEXT: [[XLT2:%.*]] = icmp ult i32 [[X]], 2
1556+
; CHECK-NEXT: [[AND:%.*]] = and i1 [[XGE1]], [[XLT2]]
1557+
; CHECK-NEXT: br i1 [[AND]], label [[PHI:%.*]], label [[NOPE:%.*]]
1558+
; CHECK: nope:
1559+
; CHECK-NEXT: br label [[PHI]]
1560+
; CHECK: phi:
1561+
; CHECK-NEXT: ret i1 true
1562+
;
1563+
entry:
1564+
%xge1 = icmp uge i32 %x, 1
1565+
%xlt2 = icmp ult i32 %x, 2
1566+
%and = and i1 %xge1, %xlt2
1567+
br i1 %and, label %phi, label %nope
1568+
nope:
1569+
br label %phi
1570+
phi:
1571+
%res = phi i32 [ %x, %entry ], [ 1, %nope ]
1572+
%ret = icmp uge i32 %res, 1
1573+
ret i1 %ret
1574+
}

llvm/test/Transforms/Util/PredicateInfo/testandor.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -998,9 +998,9 @@ define void @test_assume_deep_and_tree(i1 %a1) {
998998
define i32 @test_and_with_phinode(i32 %x) {
999999
; CHECK-LABEL: @test_and_with_phinode(
10001000
; CHECK-NEXT: entry:
1001-
; CHECK-NEXT: [[XGT0:%.*]] = icmp uge i32 [[X:%.*]], 1
1002-
; CHECK-NEXT: [[XLT1:%.*]] = icmp ult i32 [[X]], 2
1003-
; CHECK-NEXT: [[AND:%.*]] = and i1 [[XGT0]], [[XLT1]]
1001+
; CHECK-NEXT: [[XGE1:%.*]] = icmp uge i32 [[X:%.*]], 1
1002+
; CHECK-NEXT: [[XLT2:%.*]] = icmp ult i32 [[X]], 2
1003+
; CHECK-NEXT: [[AND:%.*]] = and i1 [[XGE1]], [[XLT2]]
10041004
; CHECK: [[X_0_1:%.*]] = bitcast i32 [[X]] to i32
10051005
; CHECK: [[X_0_2:%.*]] = bitcast i32 [[X_0_1]] to i32
10061006
; CHECK-NEXT: br i1 [[AND]], label [[PHI:%.*]], label [[NOPE:%.*]]
@@ -1011,9 +1011,9 @@ define i32 @test_and_with_phinode(i32 %x) {
10111011
; CHECK-NEXT: ret i32 [[RES]]
10121012
;
10131013
entry:
1014-
%xgt0 = icmp uge i32 %x, 1
1015-
%xlt1 = icmp ult i32 %x, 2
1016-
%and = and i1 %xgt0, %xlt1
1014+
%xge1 = icmp uge i32 %x, 1
1015+
%xlt2 = icmp ult i32 %x, 2
1016+
%and = and i1 %xge1, %xlt2
10171017
br i1 %and, label %phi, label %nope
10181018
nope:
10191019
br label %phi

0 commit comments

Comments
 (0)