llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Memcpy created out a loop by LoopIdiom is not marked tailcall

Open dseredkin opened this issue 4 years ago • 8 comments

There seems to be possible a small enhancement for lowering memcpy that is created out of a loop by LoopIdiom. It should be identical to the one that was written manually in the original code. However, it differs when either -Os or -Oz is present.

See an example https://godbolt.org/z/116M9PnK9

It may be a backend problem with -Os because LoopIdiom can recognize it in that case, but it fails to do that for -Oz.

GCC produces the same code for that.

dseredkin avatar Jan 29 '22 11:01 dseredkin

@llvm/issue-subscribers-backend-arm

llvmbot avatar Jan 29 '22 11:01 llvmbot

@llvm/issue-subscribers-backend-aarch64

llvmbot avatar Jan 29 '22 11:01 llvmbot

Nothing is marking the memcpy as tailcallable after the loop idiom recognition pass. It looks like TailCallElim usually marks memcpy. But that is only run before the LoopIdiomRecognizer.

davemgreen avatar Jan 30 '22 12:01 davemgreen

If https://reviews.llvm.org/D60031 lands, it should be cheap tu run TailCallMarkPass after loopidiom as well.

@jdoerfert

davidbolvansky avatar Jan 31 '22 17:01 davidbolvansky

If https://reviews.llvm.org/D60031 lands, it should be cheap tu run TailCallMarkPass after loopidiom as well.

@jdoerfert

Can someone rebase, test, land the patch? Hideto is not that active anymore and I will at least not have time to do so rn.

jdoerfert avatar Jan 31 '22 18:01 jdoerfert

I was looking at the similar #47852 and proposed a patch that would just add another round of TailCallElim as-is: https://reviews.llvm.org/D130374

rotateright avatar Jul 25 '22 14:07 rotateright

Should be fixed with: bfb9b8e075ee32197157ccaf0c301122ca9b81af

rotateright avatar Jul 26 '22 12:07 rotateright

@llvm/issue-subscribers-clang-codegen

llvmbot avatar Jul 26 '22 13:07 llvmbot