[PATCH] D124228: [NFC][NewGVN][LoadCoercion] Add new tests for future commit
Konstantina Mitropoulou via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 15 08:40:52 PDT 2022
kmitropoulou added a comment.
In D124228#3584866 <https://reviews.llvm.org/D124228#3584866>, @foad wrote:
> In D124228#3583946 <https://reviews.llvm.org/D124228#3583946>, @kmitropoulou wrote:
>
>> In D124228#3577317 <https://reviews.llvm.org/D124228#3577317>, @foad wrote:
>>
>>> LGTM. Could also use a common "GVN" prefix if you want (and if there are any tests at all where old and new gvn produce the same result).
>>
>> I am not sure what you mean. The old and new GVN might not have exactly the same output for load coercion e.g. in https://reviews.llvm.org/D124230 - test5, test 6 and test8 .
>
> I mean if you write the RUN lines like this then update_test_checks is clever enough to use the GVN prefix if both passes produce identical results for a particular function, or separate OLDGVN and NEWGVN and prefixes if they produce different results:
>
> ; RUN: opt -S -gvn < %s | FileCheck %s -check-prefixes=GVN,OLDGVN
> ; RUN: opt -S -newgvn < %s | FileCheck %s -check-prefixes=GVN,NEWGVN
>
> For example, at the moment I get different results on test1:
>
> define i8 @test1(i32* %P1) {
> ; OLDGVN-LABEL: @test1(
> ; OLDGVN-NEXT: [[V1:%.*]] = load i32, i32* [[P1:%.*]], align 4
> ; OLDGVN-NEXT: [[P2:%.*]] = bitcast i32* [[P1]] to i8*
> ; OLDGVN-NEXT: [[TMP1:%.*]] = trunc i32 [[V1]] to i8
> ; OLDGVN-NEXT: [[V4:%.*]] = add i8 [[TMP1]], [[TMP1]]
> ; OLDGVN-NEXT: ret i8 [[V4]]
> ;
> ; NEWGVN-LABEL: @test1(
> ; NEWGVN-NEXT: [[V1:%.*]] = load i32, i32* [[P1:%.*]], align 4
> ; NEWGVN-NEXT: [[P2:%.*]] = bitcast i32* [[P1]] to i8*
> ; NEWGVN-NEXT: [[V2:%.*]] = load i8, i8* [[P2]], align 1
> ; NEWGVN-NEXT: [[V3:%.*]] = trunc i32 [[V1]] to i8
> ; NEWGVN-NEXT: [[V4:%.*]] = add i8 [[V2]], [[V3]]
> ; NEWGVN-NEXT: ret i8 [[V4]]
> ;
> %V1 = load i32, i32* %P1
> %P2 = bitcast i32* %P1 to i8*
> %V2 = load i8, i8* %P2
> %V3 = trunc i32 %V1 to i8
> %V4 = add i8 %V2, %V3
> ret i8 %V4
> }
>
> but identical results on test4:
>
> define <{<2 x i32>, i32}> @test4(i8* %P) {
> ; GVN-LABEL: @test4(
> ; GVN-NEXT: Entry:
> ; GVN-NEXT: [[P2:%.*]] = bitcast i8* [[P:%.*]] to i32*
> ; GVN-NEXT: [[V2:%.*]] = load i32, i32* [[P2]], align 4
> ; GVN-NEXT: [[P1:%.*]] = bitcast i8* [[P]] to <2 x i32>*
> ; GVN-NEXT: [[V1:%.*]] = load <2 x i32>, <2 x i32>* [[P1]], align 8
> ; GVN-NEXT: [[I1:%.*]] = insertvalue <{ <2 x i32>, i32 }> poison, <2 x i32> [[V1]], 0
> ; GVN-NEXT: [[I2:%.*]] = insertvalue <{ <2 x i32>, i32 }> [[I1]], i32 [[V2]], 1
> ; GVN-NEXT: ret <{ <2 x i32>, i32 }> [[I2]]
> ;
> Entry:
> %P2 = bitcast i8* %P to i32*
> %V2 = load i32, i32* %P2
> %P1 = bitcast i8* %P to <2 x i32>*
> %V1 = load <2 x i32>, <2 x i32>* %P1
> %I1 = insertvalue <{<2 x i32>, i32}> poison, <2 x i32> %V1, 0
> %I2 = insertvalue <{<2 x i32>, i32}> %I1, i32 %V2, 1
> ret <{<2 x i32>, i32}> %I2
> }
>
> I think this is nice because it is really easy to see where the remaining differences are.
Thanks Jay :) I am going to update all the tests.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124228/new/
https://reviews.llvm.org/D124228
More information about the llvm-commits
mailing list