[PATCH] D136201: [InstCombine] Handle PHI nodes when eliminating constant memcpy
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 1 01:56:37 PDT 2022
nikic added a comment.
In D136201#3897529 <https://reviews.llvm.org/D136201#3897529>, @gandhi21299 wrote:
> The minor variant compiles correctly actually, no transformation applies so the code stays the same.
I just tried this, and the memcpy does seem to get dropped:
@g1 = constant [32 x i8] zeroinitializer
define i32 @test1(i1 %c, ptr %ptr) {
entry:
%a = alloca [32 x i8]
br i1 %c, label %if, label %join
if:
br label %join
join:
%phi = phi ptr [ %a, %if ], [ %ptr, %entry ]
call void @llvm.memcpy.p0.p0.i64(ptr %phi, ptr @g1, i64 32, i1 false)
%v = load i32, ptr %phi
ret i32 %v
}
declare void @llvm.memcpy.p0.p0.i64(ptr, ptr, i64, i1)
; RUN: opt -S -instcombine < %s
@g1 = constant [32 x i8] zeroinitializer
define i32 @test1(i1 %c, ptr %ptr) {
entry:
br i1 %c, label %if, label %join
if: ; preds = %entry
br label %join
join: ; preds = %if, %entry
%phi = phi ptr [ @g1, %if ], [ %ptr, %entry ]
%v = load i32, ptr %phi, align 4
ret i32 %v
}
; Function Attrs: argmemonly nocallback nofree nounwind willreturn
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136201/new/
https://reviews.llvm.org/D136201
More information about the llvm-commits
mailing list