[llvm] [DAG] Lower frem of power-2 using div/trunc/mul+sub (PR #91148)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Mon May 6 01:10:58 PDT 2024
================
@@ -17261,6 +17262,25 @@ SDValue DAGCombiner::visitFREM(SDNode *N) {
if (SDValue NewSel = foldBinOpIntoSelect(N))
return NewSel;
+ if (ConstantFPSDNode *C1 = isConstOrConstSplatFP(N1, true)) {
+ bool IsExact;
+ APSInt C1I(64, 0);
+ if (C1->getValueAPF().isInteger() && !C1->getValueAPF().isNegative() &&
+ C1->getValueAPF().convertToInteger(C1I, APFloat::rmTowardZero,
+ &IsExact) == APFloat::opOK &&
+ IsExact && isPowerOf2_64(C1I.getSExtValue()) &&
----------------
jayfoad wrote:
```suggestion
if (C1->getValueAPF().getExactLog2() >= 0 &&
```
https://github.com/llvm/llvm-project/pull/91148
More information about the llvm-commits
mailing list