[PATCH] D130508: [RISCV] Teach translateSetCCForBranch to help improve constant materialization.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 12:58:35 PDT 2022


craig.topper added inline comments.


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:1417
+      // Or X > C to C >= C+1 if it could use LUI.
+      if (C == -1 ||
+          (!isInt<12>(C) && isInt<12>(C + 1)) ||
----------------
reames wrote:
> Can't we generalize this to be if RISCVMatInt::getIntMatCost(C+1) < RISCVMatInt::getIntMatCost(C)?
I was trying to be a little conservative if the constant required multiple instructions and was used by other instructions. Changing it could introduce multiple slightly different constants. I figured creating an LUI or ADDI wasn't as bad.

Maybe I should check one use and/or opaque constant?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130508



More information about the llvm-commits mailing list