top | item 46978826

(no title)

ndesaulniers | 18 days ago

Was looking at the llvm case with the dead store to the stack.

https://godbolt.org/z/Kb736onb4

  \*\* IR Dump After Expand memcmp() to load/stores (expand-memcmp) \*\*
  ; Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: read) uwtable
  define dso_local noundef zeroext i1 @isAllZeros(ptr noundef nonnull readonly align 4 captures(none) dereferenceable(8) %0) local_unnamed_addr #0 {
    %2 = alloca %"struct.std::array", align 8
    call void @llvm.lifetime.start.p0(ptr %2)
    store i64 0, ptr %2, align 8
    %3 = load i64, ptr %0, align 4
    %4 = load i64, ptr %2, align 8
    %5 = icmp ne i64 %3, %4
    %6 = zext i1 %5 to i32
    %7 = icmp eq i32 %6, 0
    call void @llvm.lifetime.end.p0(ptr %2)
    ret i1 %7
  }
It looks like expand-memcmp in the backend converts a call to bcmp to multiple loads/stores. Perhaps expand-memcmp should then do a round of store-to-load forwarding.

Filed https://github.com/llvm/llvm-project/issues/180991 which I think is what the author should do in cases like this (rather than a blog post).

discuss

order

No comments yet.