Open Quuxplusone opened 8 years ago
Attached bug2.tar
(10240 bytes, application/x-tar): Tar file of script and input files
When SimplifyCFG speculates the execution of a block, the statements in that block will have execution frequency raise to that of the dominating block. For the "then" clause this raises the frequency from 0 to a same as the trip count of the loop.
The same thing would happen to the "else" block but in this case the operations are loop invariant and so get housed out of the loop and instead of getting the same frequency as the loop body, they the much lower estimate of the loop header.
This is an interesting case: the branch weights become opposite in optimized binary.
But for this case, neither LICM nor if-conversion replies on profile data. As a result, the same optimization will take place no matter how wrong the profile is when profile is used. And after if-conversion, the profile correctness would not matter at all for later optimizations. So I think we should be able to live with the incorrect profile?
Code layout can be bad with this
Re #3 -- to clarify : if ifcvt uses profile data to make decision and do not convert highly biased branch, then bad profile can have bigger impact.
Also, in CodeGen Prepare, there is code that attempts to undo a select based on branch weights. isFormingBranchFromSelectProfitable(). Getting this wrong compromises hmmer in Spec2006
(In reply to comment #5)
> Also, in CodeGen Prepare, there is code that attempts to undo a select based
> on branch weights. isFormingBranchFromSelectProfitable(). Getting this
> wrong compromises hmmer in Spec2006
Can you file a separate bug for that (ideally with a reduced test case)? Thanks!
bug2.tar
(10240 bytes, application/x-tar)