[PATCH] D81827: [CGP] Convert phi types

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 15 01:36:15 PDT 2020


dmgreen created this revision.
dmgreen added reviewers: efriedma, craig.topper, samparker, SjoerdMeijer.
Herald added subscribers: jfb, hiraditya, kristof.beyls.
Herald added a project: LLVM.

If a collection of interconnected phi nodes is only ever loaded, stored or bitcast then we can convert the whole set to the bitcast type, potentially helping to reduce the number of register moves needed as the phi's are passed across basic block boundaries. This has to be done in CodegenPrepare as it naturally straddles basic blocks. It just looks from phi nodes, looking at uses and operands for a collection of nodes that all together are bitcast between float and integer types. We record visited phi nodes to not have to process them more than once. The whole subgraph is then replaced with a new type. Loads and Stores are bitcast to the correct type, which should then be folded into the load/store, changing it's type.

This comes up in the biquad testcase due to the way MVE needs to keep values in integer registers. I have also seen it come up from aarch64 partner example code, where a complicated set of sroa/inlining produced integer phis, where float would have been a better choice. I can't provide an example unfortunately (and you might argue it should be fixed earlier in that case). It also comes up in an X86 atomic test case, which looks better and functionally OK to my untrained eyes. I can make this ARM or MVE only, if that would be better. I also added extract_element handling, which increased this from a 60% improvement to a 109% improvement.


https://reviews.llvm.org/D81827

Files:
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/test/CodeGen/AArch64/convertphitype.ll
  llvm/test/CodeGen/Thumb2/mve-float32regloops.ll
  llvm/test/CodeGen/X86/atomicf128.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81827.270673.patch
Type: text/x-patch
Size: 28944 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200615/7fe056a9/attachment.bin>


More information about the llvm-commits mailing list