{"push_id":852664682,"size":1,"distinct_size":1,"ref":"refs/heads/master","head":"21ea6085dc581f8b6d4eb01617221185ce57dc42","before":"c3c89b471b2e30c85c37d17984e1260c56b6d06f","commits":[{"sha":"21ea6085dc581f8b6d4eb01617221185ce57dc42","author":{"email":"f4a524c472c347a18d71daaa7c4ae51db69c69da@arm.com","name":"James Molloy"},"message":"[SimplifyCFG] Merge conditional stores\n\nWe can often end up with conditional stores that cannot be speculated. They can come from fairly simple, idiomatic code:\n\n  if (c & flag1)\n    *a = x;\n  if (c & flag2)\n    *a = y;\n  ...\n\nThere is no dominating or post-dominating store to a, so it is not legal to move the store unconditionally to the end of the sequence and cache the intermediate result in a register, as we would like to.\n\nIt is, however, legal to merge the stores together and do the store once:\n\n  tmp = undef;\n  if (c & flag1)\n    tmp = x;\n  if (c & flag2)\n    tmp = y;\n  if (c & flag1 || c & flag2)\n    *a = tmp;\n\nThe real power in this optimization is that it allows arbitrary length ladders such as these to be completely and trivially if-converted. The typical code I'd expect this to trigger on often uses binary-AND with constants as the condition (as in the above example), which means the ending condition can simply be truncated into a single binary-AND too: 'if (c & (flag1|flag2))'. As in the general case there are bitwise operators here, the ladder can often be optimized further too.\n\nThis optimization involves potentially increasing register pressure. Even in the simplest case, the lifetime of the first predicate is extended. This can be elided in some cases such as using binary-AND on constants, but not in the general case. Threading 'tmp' through all branches can also increase register pressure.\n\nThe optimization as in this patch is enabled by default but kept in a very conservative mode. It will only optimize if it thinks the resultant code should be if-convertable, and additionally if it can thread 'tmp' through at least one existing PHI, so it will only ever in the worst case create one more PHI and extend the lifetime of a predicate.\n\nThis doesn't trigger much in LNT, unfortunately, but it does trigger in a big way in a third party test suite.\n\ngit-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252051 91177308-0d34-0410-b5e6-96231b3b80d8","distinct":true,"url":"https://api.github.com/repos/llvm-project/llvm/commits/21ea6085dc581f8b6d4eb01617221185ce57dc42"}]}