[PATCH] D109124: [ARM] Implement target hook function to decide folding (mul (add x, c1), c2)

Ben Shi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 3 22:47:49 PDT 2021


benshi001 added a comment.

In D109124#2982331 <https://reviews.llvm.org/D109124#2982331>, @dmgreen wrote:

> Could this use ConstantMaterializationCost from ARMBaseInstrInfo for the costs of materializing the constants? That way it should just work with any architecture or constants, with some simple checking for which will produce the lowest total cost. It might need to include isLegalAddImmediate too, but that should be handling Thumb and Arm already too.

Thanks for your advice. I have changed to using  `ConstantMaterializationCost`, it does work for all arm/thumb targets.

One more concern, this change generates better code for most cases, except the ARMV5/ARMV6 tags in `@test_urem_vec` in `llvm/test/CodeGen/ARM/urem-seteq-illegal-types.ll`. The total number of ARMV5 instructions decreases from 38 to 36, and ARMV6 also decreases from 38 to 36. It looks like improvement than regression. But I am sure you can accept such a large change.

So in my previous patch revision, I left ARMv5/v6 as TODO and only did for subtargets with movw/movt.

What is the best form do you think? I can fall back to thumb + arm_with_movt, which I thought to be better.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109124/new/

https://reviews.llvm.org/D109124



More information about the llvm-commits mailing list