llvm-project
llvm-project copied to clipboard
Failure to reach fixpoint in 1st iteration when constant folding libcall
https://llvm.godbolt.org/z/456M4eq6f
We constant fold the call to floor, but it's not trivially dead so it hangs around after being RAUWd. Maybe we should mark the TargetLibraryInfo::hasOptimizedCodeGen functions as trivially dead?
I believe the problem is that prepareWorklist() fails to add the instruction to the worklist if it constant folds but is not trivially dead.
(The specific example will optimize in one iteration in practice, because it will have inferred attributes that make it trivially dead.)
Hello. I have tried a fix based on nikic's suggestion and can provide a PR.