Skip to content

Commit d13bcb6

Browse files
[GVN] Additional test coverage for findLoadToHoistIntoPred (NFC)
Add coverage exercizing `isNonLocal` when hoisting identical loads in `findLoadToHoistIntoPred`, previously lacking.
1 parent fc08613 commit d13bcb6

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

llvm/test/Transforms/GVN/PRE/pre-load.ll

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,3 +1503,51 @@ wrong:
15031503
exit:
15041504
ret void
15051505
}
1506+
1507+
; Allow the load to be made available on the edge (%entry, %if.end) as part of PRE,
1508+
; but ensure `%identical.l` is not hoisted to its predecessor due to the local
1509+
; dependency with the call.
1510+
1511+
define i32 @test24(ptr noalias %p, ptr noalias %q, i1 %c) {
1512+
; MDEP-LABEL: @test24(
1513+
; MDEP-NEXT: entry:
1514+
; MDEP-NEXT: br i1 [[C:%.*]], label [[ENTRY_IF_END_CRIT_EDGE:%.*]], label [[IF_THEN:%.*]]
1515+
; MDEP: entry.if.end_crit_edge:
1516+
; MDEP-NEXT: [[VV_PRE:%.*]] = load i32, ptr [[X:%.*]], align 4
1517+
; MDEP-NEXT: br label [[IF_END:%.*]]
1518+
; MDEP: if.then:
1519+
; MDEP-NEXT: call void @opaque(ptr [[X]])
1520+
; MDEP-NEXT: [[UU:%.*]] = load i32, ptr [[X]], align 4
1521+
; MDEP-NEXT: store i32 [[UU]], ptr [[R:%.*]], align 4
1522+
; MDEP-NEXT: br label [[IF_END]]
1523+
; MDEP: if.end:
1524+
; MDEP-NEXT: [[VV:%.*]] = phi i32 [ [[VV_PRE]], [[ENTRY_IF_END_CRIT_EDGE]] ], [ [[UU]], [[IF_THEN]] ]
1525+
; MDEP-NEXT: ret i32 [[VV]]
1526+
;
1527+
; MSSA-LABEL: @test24(
1528+
; MSSA-NEXT: entry:
1529+
; MSSA-NEXT: br i1 [[C:%.*]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
1530+
; MSSA: if.then:
1531+
; MSSA-NEXT: call void @opaque(ptr [[X:%.*]])
1532+
; MSSA-NEXT: [[UU:%.*]] = load i32, ptr [[X]], align 4
1533+
; MSSA-NEXT: store i32 [[UU]], ptr [[R:%.*]], align 4
1534+
; MSSA-NEXT: br label [[IF_END]]
1535+
; MSSA: if.end:
1536+
; MSSA-NEXT: [[VV:%.*]] = load i32, ptr [[X]], align 4
1537+
; MSSA-NEXT: ret i32 [[VV]]
1538+
;
1539+
entry:
1540+
br i1 %c, label %if.end, label %if.then
1541+
1542+
if.then:
1543+
call void @opaque(ptr %p)
1544+
%identical.l = load i32, ptr %p, align 4
1545+
store i32 %identical.l, ptr %q, align 4
1546+
br label %if.end
1547+
1548+
if.end:
1549+
%l = load i32, ptr %p, align 4
1550+
ret i32 %l
1551+
}
1552+
1553+
declare void @opaque(ptr) nounwind willreturn

0 commit comments

Comments
 (0)