mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
[DSE] Bail out on MemoryPhis when deleting stores at end of function.
When deleting stores at the end of a function, we have to do PHI translation, otherwise we might miss reads in different iterations of a loop. See multiblock-loop-carried-dependence.ll for details. This fixes a mis-compile and surprisingly also increases the number of eliminated stores from 26047 to 26572 for MultiSource/SPEC2000/SPEC2006 on X86 with -O3 -flto. This is most likely because we save budget by not exploring through MemoryPhis, which are less likely to result in valid candidates for elimination. The issue was reported post-commit for fb109c42d91c.
This commit is contained in:
parent
2fae14a0b6
commit
ad8e41fb76
@ -1776,10 +1776,12 @@ struct DSEState {
|
||||
}
|
||||
|
||||
MemoryAccess *UseAccess = WorkList[I];
|
||||
if (isa<MemoryPhi>(UseAccess)) {
|
||||
PushMemUses(UseAccess);
|
||||
continue;
|
||||
}
|
||||
// Simply adding the users of MemoryPhi to the worklist is not enough,
|
||||
// because we might miss read clobbers in different iterations of a loop,
|
||||
// for example.
|
||||
// TODO: Add support for phi translation to handle the loop case.
|
||||
if (isa<MemoryPhi>(UseAccess))
|
||||
return false;
|
||||
|
||||
// TODO: Checking for aliasing is expensive. Consider reducing the amount
|
||||
// of times this is called and/or caching it.
|
||||
|
@ -29,6 +29,9 @@ define void @test.1() {
|
||||
; CHECK-NEXT: [[PTR_IV_2:%.*]] = getelementptr inbounds [100 x i32], [100 x i32]* [[A]], i64 0, i64 [[IV_2]]
|
||||
; CHECK-NEXT: [[L_0:%.*]] = load i32, i32* [[PTR_IV_2]], align 4
|
||||
; CHECK-NEXT: call void @use(i32 [[L_0]])
|
||||
; CHECK-NEXT: [[ADD:%.*]] = add nsw i64 [[IV_2]], 1
|
||||
; CHECK-NEXT: [[PTR_IV_2_ADD_1:%.*]] = getelementptr inbounds [100 x i32], [100 x i32]* [[A]], i64 0, i64 [[ADD]]
|
||||
; CHECK-NEXT: store i32 10, i32* [[PTR_IV_2_ADD_1]], align 4
|
||||
; CHECK-NEXT: [[L_1:%.*]] = load i32, i32* [[PTR_IV_2]], align 4
|
||||
; CHECK-NEXT: call void @use(i32 [[L_1]])
|
||||
; CHECK-NEXT: [[IV_2_NEXT]] = add nsw i64 [[IV_2]], 1
|
||||
|
@ -180,6 +180,7 @@ define void @test27() {
|
||||
; CHECK-NEXT: br i1 true, label [[BB2:%.*]], label [[BB3:%.*]]
|
||||
; CHECK: bb2:
|
||||
; CHECK-NEXT: [[M:%.*]] = call noalias i8* @malloc(i64 10)
|
||||
; CHECK-NEXT: store i8 1, i8* [[M]], align 1
|
||||
; CHECK-NEXT: br label [[BB3]]
|
||||
; CHECK: bb3:
|
||||
; CHECK-NEXT: [[R:%.*]] = phi i8* [ null, [[BB1:%.*]] ], [ [[M]], [[BB2]] ]
|
||||
|
@ -123,10 +123,18 @@ bb3:
|
||||
define void @alloca_1(i1 %c) {
|
||||
; CHECK-LABEL: @alloca_1(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: [[P_ALLOCA:%.*]] = alloca [32 x i32], align 4
|
||||
; CHECK-NEXT: [[P:%.*]] = bitcast [32 x i32]* [[P_ALLOCA]] to i32*
|
||||
; CHECK-NEXT: [[ARRAYIDX0:%.*]] = getelementptr inbounds i32, i32* [[P]], i64 1
|
||||
; CHECK-NEXT: [[P3:%.*]] = bitcast i32* [[ARRAYIDX0]] to i8*
|
||||
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds i8, i8* [[P3]], i64 4
|
||||
; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[TMP0]], i8 0, i64 24, i1 false)
|
||||
; CHECK-NEXT: br i1 [[C:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
|
||||
; CHECK: bb1:
|
||||
; CHECK-NEXT: br label [[BB3:%.*]]
|
||||
; CHECK: bb2:
|
||||
; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i32, i32* [[P]], i64 1
|
||||
; CHECK-NEXT: store i32 1, i32* [[ARRAYIDX1]], align 4
|
||||
; CHECK-NEXT: br label [[BB3]]
|
||||
; CHECK: bb3:
|
||||
; CHECK-NEXT: ret void
|
||||
@ -152,10 +160,20 @@ bb3:
|
||||
define void @alloca_2(i1 %c) {
|
||||
; CHECK-LABEL: @alloca_2(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: [[P_ALLOCA:%.*]] = alloca [32 x i32], align 4
|
||||
; CHECK-NEXT: [[P:%.*]] = bitcast [32 x i32]* [[P_ALLOCA]] to i32*
|
||||
; CHECK-NEXT: [[ARRAYIDX0:%.*]] = getelementptr inbounds i32, i32* [[P]], i64 1
|
||||
; CHECK-NEXT: [[P3:%.*]] = bitcast i32* [[ARRAYIDX0]] to i8*
|
||||
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds i8, i8* [[P3]], i64 4
|
||||
; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[TMP0]], i8 0, i64 24, i1 false)
|
||||
; CHECK-NEXT: br i1 [[C:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
|
||||
; CHECK: bb1:
|
||||
; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i32, i32* [[P]], i64 1
|
||||
; CHECK-NEXT: store i32 1, i32* [[ARRAYIDX1]], align 4
|
||||
; CHECK-NEXT: br label [[BB3:%.*]]
|
||||
; CHECK: bb2:
|
||||
; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, i32* [[P]], i64 1
|
||||
; CHECK-NEXT: store i32 1, i32* [[ARRAYIDX2]], align 4
|
||||
; CHECK-NEXT: br label [[BB3]]
|
||||
; CHECK: bb3:
|
||||
; CHECK-NEXT: ret void
|
||||
|
Loading…
Reference in New Issue
Block a user