[llvm] [BPF] Support signed division at cpu v1 with constant divisor (PR #110627)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 1 07:27:52 PDT 2024


================
@@ -565,7 +565,12 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
       if (!isa<ConstantInt>(Inst.getOperand(1)))
         return false;
       EVT VT = getTLI()->getValueType(DL, Inst.getType());
-      return !getTLI()->isIntDivCheap(VT, Fn.getAttributes());
+
+      bool IsSigned = true;
+      if (Inst.getOpcode() == Instruction::SDiv ||
+          Inst.getOpcode() == Instruction::SRem)
+        IsSigned = false;
----------------
4ast wrote:

I don't think we need to differentiate signed vs unsigned here.
Both kinds of division are expensive. This transformation is necessary in all cases.
That should avoid adding isSigned everywhere.

https://github.com/llvm/llvm-project/pull/110627


More information about the llvm-commits mailing list