[PATCH] D126089: [WPD] Try harder to find assumes through phis
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 26 09:53:19 PDT 2022
aeubanks added a comment.
It's this bit of code: https://crsrc.org/c/third_party/dawn/src/dawn/native/d3d12/ShaderModuleD3D12.cpp;drc=d6b2501be2351fc048727d79acc71f3780d89cf2;l=813
with opaque pointers we're able to sink more common code out of the two branches
typed pointers after pre-link:
; Function Attrs: mustprogress nounwind null_pointer_is_valid optsize sspstrong uwtable
define dso_local void @"?GetD3D12ShaderBytecode at CompiledShader@d3d12 at native@dawn@@QEBA?AUD3D12_SHADER_BYTECODE@@XZ"(%474* nocapture noundef readonly align 8 dereferenceable_or_null(24) %0, %738*
noalias nocapture writeonly sret(%738) align 8 %1) local_unnamed_addr #4 align 2 !type !184 {
%3 = getelementptr inbounds %474, %474* %0, i64 0, i32 0, i32 0
%4 = load %476*, %476** %3, align 8
%5 = icmp eq %476* %4, null
br i1 %5, label %22, label %6
6: ; preds = %2
%7 = bitcast %476* %4 to i8* (%476*)***
%8 = load i8* (%476*)**, i8* (%476*)*** %7, align 8
%9 = bitcast i8* (%476*)** %8 to i8*
%10 = tail call i1 @llvm.type.test(i8* %9, metadata !"?AUID3D10Blob@@")
tail call void @llvm.assume(i1 %10)
%11 = getelementptr inbounds i8* (%476*)*, i8* (%476*)** %8, i64 3
%12 = load i8* (%476*)*, i8* (%476*)** %11, align 8
%13 = tail call noundef i8* %12(%476* noundef nonnull align 8 dereferenceable_or_null(8) %4) #16
%14 = load %476*, %476** %3, align 8
%15 = bitcast %476* %14 to i64 (%476*)***
%16 = load i64 (%476*)**, i64 (%476*)*** %15, align 8
%17 = bitcast i64 (%476*)** %16 to i8*
%18 = tail call i1 @llvm.type.test(i8* %17, metadata !"?AUID3D10Blob@@")
tail call void @llvm.assume(i1 %18)
%19 = getelementptr inbounds i64 (%476*)*, i64 (%476*)** %16, i64 4
%20 = load i64 (%476*)*, i64 (%476*)** %19, align 8
%21 = tail call noundef i64 %20(%476* noundef align 8 dereferenceable_or_null(8) %14) #16
br label %40
22: ; preds = %2
%23 = getelementptr inbounds %474, %474* %0, i64 0, i32 1, i32 0
%24 = load %478*, %478** %23, align 8, !nonnull !185
%25 = bitcast %478* %24 to i8* (%478*)***
%26 = load i8* (%478*)**, i8* (%478*)*** %25, align 8
%27 = bitcast i8* (%478*)** %26 to i8*
%28 = tail call i1 @llvm.type.test(i8* %27, metadata !"?AUIDxcBlob@@")
tail call void @llvm.assume(i1 %28)
%29 = getelementptr inbounds i8* (%478*)*, i8* (%478*)** %26, i64 3
%30 = load i8* (%478*)*, i8* (%478*)** %29, align 8
%31 = tail call noundef i8* %30(%478* noundef nonnull align 8 dereferenceable_or_null(8) %24) #16
%32 = load %478*, %478** %23, align 8
%33 = bitcast %478* %32 to i64 (%478*)***
%34 = load i64 (%478*)**, i64 (%478*)*** %33, align 8
%35 = bitcast i64 (%478*)** %34 to i8*
%36 = tail call i1 @llvm.type.test(i8* %35, metadata !"?AUIDxcBlob@@")
tail call void @llvm.assume(i1 %36)
%37 = getelementptr inbounds i64 (%478*)*, i64 (%478*)** %34, i64 4
%38 = load i64 (%478*)*, i64 (%478*)** %37, align 8
%39 = tail call noundef i64 %38(%478* noundef align 8 dereferenceable_or_null(8) %32) #16
br label %40
40: ; preds = %22, %6
%41 = phi i8* [ %31, %22 ], [ %13, %6 ]
%42 = phi i64 [ %39, %22 ], [ %21, %6 ]
%43 = getelementptr inbounds %738, %738* %1, i64 0, i32 0
store i8* %41, i8** %43, align 8
%44 = getelementptr inbounds %738, %738* %1, i64 0, i32 1
store i64 %42, i64* %44, align 8
ret void
}
opaque pointers after pre-link
; Function Attrs: mustprogress nounwind null_pointer_is_valid optsize sspstrong uwtable
define dso_local void @"?GetD3D12ShaderBytecode at CompiledShader@d3d12 at native@dawn@@QEBA?AUD3D12_SHADER_BYTECODE@@XZ"(ptr nocapture noundef readonly align 8 dereferenceable_or_null(24) %0, ptr noalias nocapture writeonly sret(%435) align 8 %1) local_unnamed_addr #4 align 2 !type !184 {
%3 = load ptr, ptr %0, align 8
%4 = icmp eq ptr %3, null
br i1 %4, label %14, label %5
5: ; preds = %2
%6 = load ptr, ptr %3, align 8
%7 = tail call i1 @llvm.type.test(ptr %6, metadata !"?AUID3D10Blob@@")
tail call void @llvm.assume(i1 %7)
%8 = getelementptr inbounds ptr, ptr %6, i64 3
%9 = load ptr, ptr %8, align 8
%10 = tail call noundef ptr %9(ptr noundef nonnull align 8 dereferenceable_or_null(8) %3) #16
store ptr %10, ptr %1, align 8
%11 = load ptr, ptr %0, align 8
%12 = load ptr, ptr %11, align 8
%13 = tail call i1 @llvm.type.test(ptr %12, metadata !"?AUID3D10Blob@@")
br label %25
14: ; preds = %2
%15 = getelementptr inbounds %157, ptr %0, i64 0, i32 1
%16 = load ptr, ptr %15, align 8, !nonnull !185
%17 = load ptr, ptr %16, align 8
%18 = tail call i1 @llvm.type.test(ptr %17, metadata !"?AUIDxcBlob@@")
tail call void @llvm.assume(i1 %18)
%19 = getelementptr inbounds ptr, ptr %17, i64 3
%20 = load ptr, ptr %19, align 8
%21 = tail call noundef ptr %20(ptr noundef nonnull align 8 dereferenceable_or_null(8) %16) #16
store ptr %21, ptr %1, align 8
%22 = load ptr, ptr %15, align 8
%23 = load ptr, ptr %22, align 8
%24 = tail call i1 @llvm.type.test(ptr %23, metadata !"?AUIDxcBlob@@")
br label %25
25: ; preds = %14, %5
%26 = phi i1 [ %24, %14 ], [ %13, %5 ]
%27 = phi ptr [ %23, %14 ], [ %12, %5 ]
%28 = phi ptr [ %22, %14 ], [ %11, %5 ]
tail call void @llvm.assume(i1 %26)
%29 = getelementptr inbounds ptr, ptr %27, i64 4
%30 = load ptr, ptr %29, align 8
%31 = tail call noundef i64 %30(ptr noundef align 8 dereferenceable_or_null(8) %28) #16
%32 = getelementptr inbounds %435, ptr %1, i64 0, i32 1
store i64 %31, ptr %32, align 8
ret void
}
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126089/new/
https://reviews.llvm.org/D126089
More information about the llvm-commits
mailing list