[PATCH] D114128: [SROA] Add an IR to test that allocations of struct are scalarized.
David Li via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 18 09:07:30 PST 2021
davidxl added inline comments.
================
Comment at: llvm/test/Transforms/SROA/alloca-struct.ll:31
+ %retval = alloca %struct.RetValIntChar, align 4
+ %test.addr = alloca i8, align 1
+ %p.addr = alloca i64 ()*, align 8
----------------
remove %test.addr
================
Comment at: llvm/test/Transforms/SROA/alloca-struct.ll:32
+ %test.addr = alloca i8, align 1
+ %p.addr = alloca i64 ()*, align 8
+ %frombool = zext i1 %test to i8
----------------
same here
================
Comment at: llvm/test/Transforms/SROA/alloca-struct.ll:33
+ %p.addr = alloca i64 ()*, align 8
+ %frombool = zext i1 %test to i8
+ store i8 %frombool, i8* %test.addr, align 1, !tbaa !3
----------------
remove %frombool
================
Comment at: llvm/test/Transforms/SROA/alloca-struct.ll:35
+ store i8 %frombool, i8* %test.addr, align 1, !tbaa !3
+ store i64 ()* %p, i64 ()** %p.addr, align 8, !tbaa !7
+ %0 = load i8, i8* %test.addr, align 1, !tbaa !3, !range !9
----------------
Remove the above two stores
================
Comment at: llvm/test/Transforms/SROA/alloca-struct.ll:36
+ store i64 ()* %p, i64 ()** %p.addr, align 8, !tbaa !7
+ %0 = load i8, i8* %test.addr, align 1, !tbaa !3, !range !9
+ %tobool = trunc i8 %0 to i1
----------------
remove load
================
Comment at: llvm/test/Transforms/SROA/alloca-struct.ll:37
+ %0 = load i8, i8* %test.addr, align 1, !tbaa !3, !range !9
+ %tobool = trunc i8 %0 to i1
+ br i1 %tobool, label %if.then, label %if.end
----------------
remove
================
Comment at: llvm/test/Transforms/SROA/alloca-struct.ll:38
+ %tobool = trunc i8 %0 to i1
+ br i1 %tobool, label %if.then, label %if.end
+
----------------
Replace %tobool with %test
================
Comment at: llvm/test/Transforms/SROA/alloca-struct.ll:48
+if.end: ; preds = %entry
+ %1 = load i64 ()*, i64 ()** %p.addr, align 8, !tbaa !7
+ %call = call i64 %1()
----------------
remove load
================
Comment at: llvm/test/Transforms/SROA/alloca-struct.ll:49
+ %1 = load i64 ()*, i64 ()** %p.addr, align 8, !tbaa !7
+ %call = call i64 %1()
+ %2 = bitcast %struct.RetValIntChar* %retval to i64*
----------------
replace %1 with %p
================
Comment at: llvm/test/Transforms/SROA/alloca-struct.ll:61
+; Test that the alloca of struct{int, int} will be scalarized by SROA.
+define dso_local i64 @test_struct_of_two_int(i1 zeroext %test, i64 ()* %p) #0 {
+; CHECK-LABEL: @test_struct_of_two_int(
----------------
Similar cleanup can be done for this test cse.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114128/new/
https://reviews.llvm.org/D114128
More information about the llvm-commits
mailing list