[PATCH] D109360: [ARM] Mark <= -1 immediate constant as cheap
Dave Green via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 22 01:43:28 PDT 2021
dmgreen added inline comments.
================
Comment at: llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp:385
+ // We can convert <= -1 to < 0, which is generally quite cheap.
+ if (Inst && Opcode == Instruction::ICmp && Idx == 1 && Imm.isAllOnesValue()) {
+ ICmpInst::Predicate Pred = cast<ICmpInst>(Inst)->getPredicate();
----------------
samtebbs wrote:
> Can this be applied to any integer less than the maximum for the type (e.g. <= 6 to < 7) rather than just <= -1 to < 0?
Yep! I originally had it that way, but unfortunately it led to more regressions. The combiner didn't always handle the constants better to actually produce smaller code.
The 0/-1 case should be the most common, I believe, and is at least the motivating case I have.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109360/new/
https://reviews.llvm.org/D109360
More information about the llvm-commits
mailing list