[PATCH] D116616: [InstSimplify] use knownbits to fold more udiv/urem

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 5 03:12:55 PST 2022


foad added a comment.

It seems like you're using knownbits information to derive range information. It would be good to do this more universally, and in both directions.



================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:1087-1088
+        computeKnownBits(X, Q.DL, MaxRecurse, Q.AC, Q.CxtI, Q.DT);
+    Optional<bool> IsULT = KnownBits::ult(KnownX, KnownBits::makeConstant(*C));
+    if (IsULT.hasValue() && IsULT.getValue())
+      return true;
----------------
Can't you just test `if (KnownX.getMaxValue().ult(*C))`?


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

https://reviews.llvm.org/D116616



More information about the llvm-commits mailing list