[PATCH] D141188: [MergeICmps] Adapt to non-eq comparisons
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 10 13:25:25 PST 2023
aeubanks added a comment.
miscompile:
$ cat a.ll
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%"struct.media::WebrtcVideoStatsDB::VideoDescKey" = type { i8, i32, i8, i32 }
define i1 @_ZN5medianeERKNS_18WebrtcVideoStatsDB12VideoDescKeyES3_(ptr nocapture noundef readonly align 4 dereferenceable(16) %0, ptr nocapture noundef readonly align 4 dereferenceable(16) %1) {
%3 = load i8, ptr %0, align 4, !range !4, !noundef !5
%4 = load i8, ptr %1, align 4, !range !4, !noundef !5
%5 = icmp eq i8 %3, %4
br i1 %5, label %6, label %24
6: ; preds = %2
%7 = getelementptr inbounds %"struct.media::WebrtcVideoStatsDB::VideoDescKey", ptr %0, i64 0, i32 1
%8 = load i32, ptr %7, align 4
%9 = getelementptr inbounds %"struct.media::WebrtcVideoStatsDB::VideoDescKey", ptr %1, i64 0, i32 1
%10 = load i32, ptr %9, align 4
%11 = icmp eq i32 %8, %10
br i1 %11, label %12, label %24
12: ; preds = %6
%13 = getelementptr inbounds %"struct.media::WebrtcVideoStatsDB::VideoDescKey", ptr %0, i64 0, i32 2
%14 = load i8, ptr %13, align 4, !range !4, !noundef !5
%15 = getelementptr inbounds %"struct.media::WebrtcVideoStatsDB::VideoDescKey", ptr %1, i64 0, i32 2
%16 = load i8, ptr %15, align 4, !range !4, !noundef !5
%17 = icmp eq i8 %14, %16
br i1 %17, label %18, label %24
18: ; preds = %12
%19 = getelementptr inbounds %"struct.media::WebrtcVideoStatsDB::VideoDescKey", ptr %0, i64 0, i32 3
%20 = load i32, ptr %19, align 4
%21 = getelementptr inbounds %"struct.media::WebrtcVideoStatsDB::VideoDescKey", ptr %1, i64 0, i32 3
%22 = load i32, ptr %21, align 4
%23 = icmp ne i32 %20, %22
br label %24
24: ; preds = %18, %12, %6, %2
%25 = phi i1 [ true, %12 ], [ true, %6 ], [ true, %2 ], [ %23, %18 ]
ret i1 %25
}
!4 = !{i8 0, i8 2}
!5 = !{}
$ opt -passes=mergeicmps -S a.ll
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%"struct.media::WebrtcVideoStatsDB::VideoDescKey" = type { i8, i32, i8, i32 }
define i1 @_ZN5medianeERKNS_18WebrtcVideoStatsDB12VideoDescKeyES3_(ptr nocapture noundef readonly align 4 dereferenceable(16) %0, ptr nocapture noundef readonly align 4 dereferenceable(16) %1) {
%3 = load i8, ptr %0, align 1
%4 = load i8, ptr %1, align 1
%5 = icmp eq i8 %3, %4
br i1 %5, label %6, label %16
6: ; preds = %2
%7 = getelementptr inbounds %"struct.media::WebrtcVideoStatsDB::VideoDescKey", ptr %0, i64 0, i32 1
%8 = getelementptr inbounds %"struct.media::WebrtcVideoStatsDB::VideoDescKey", ptr %1, i64 0, i32 1
%memcmp = call i32 @memcmp(ptr %7, ptr %8, i64 5)
%9 = icmp eq i32 %memcmp, 0
br i1 %9, label %10, label %16
10: ; preds = %6
%11 = getelementptr inbounds %"struct.media::WebrtcVideoStatsDB::VideoDescKey", ptr %0, i64 0, i32 3
%12 = getelementptr inbounds %"struct.media::WebrtcVideoStatsDB::VideoDescKey", ptr %1, i64 0, i32 3
%13 = load i32, ptr %11, align 4
%14 = load i32, ptr %12, align 4
%15 = icmp ne i32 %13, %14
br label %16
16: ; preds = %2, %6, %10
%17 = phi i1 [ %15, %10 ], [ false, %6 ], [ false, %2 ]
ret i1 %17
}
; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @memcmp(ptr nocapture, ptr nocapture, i64) #0
attributes #0 = { nofree nounwind willreturn memory(argmem: read) }
the phi value from the entry block turns from `true` to `false`
(also the metadata for the loads in the entry block don't need to be dropped?)
will revert this patch
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D141188/new/
https://reviews.llvm.org/D141188
More information about the llvm-commits
mailing list