Prevent the folding in DAGCombine if it leads to worse code.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I have troubles with thumb and 'arm without movt/movw', so let me submit the partial change, which leads to better code for 'arm with movt/movw'.
And mark the thumb and 'arm without movt/movw' as TODOs.
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.
llvm/lib/Target/ARM/ARMISelLowering.h | ||
---|---|---|
522 | why are we passing SDValue by const-ref? These things are lightweight enough we normally pass SDValue by value. |
llvm/lib/Target/ARM/ARMISelLowering.h | ||
---|---|---|
522 | No special reason for that. Actually I did not pay attention to that const-ref in my previous patch https://reviews.llvm.org/D107711 |
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.
The urem cases look OK to me. What do the other tests look like when they have been rebased on top of D109123?
Sometimes the total instruction amount does not change, but an item in the constant pool at the end is eliminated.
why are we passing SDValue by const-ref? These things are lightweight enough we normally pass SDValue by value.