Skip to content

[MemCpyOpt or GVN] Load source from memcpy #137810

@dianqk

Description

@dianqk

The following IR can be transformed from load i24, ptr %dest to load i24, ptr %src so that we can know %arg equals %arg2.

define noundef i1 @wombat(ptr align 4 %src) {
bb:
  %dest = alloca [3 x i8], align 4
  %arg = load i24, ptr %src, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(3) %dest, ptr noundef nonnull align 4 dereferenceable(3) %src, i64 3, i1 false)
  %arg2 = load i24, ptr %dest, align 4
  %select = icmp eq i24 %arg, %arg2
  call void @snork(ptr nonnull %dest)
  ret i1 %select
}

declare void @snork(ptr)

declare void @llvm.memcpy.p0.p0.i64(ptr noalias writeonly captures(none), ptr noalias readonly captures(none), i64, i1 immarg)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions