[PATCH] D156499: [InstCombine] Fold abs of known sign operand when source is sub
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 4 09:14:53 PDT 2023
goldstein.w.n added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:1537
+
if (std::optional<bool> Sign = getKnownSign(IIOperand, II, DL, &AC, &DT)) {
+ // abs(x) -> x if x >= 0 (include abs(x-y) --> x-y where x >= y)
----------------
Sorry, noticed this a bit late, but is there a way we can avoid essentially recreating the logic below and instead just add something like `getKnownSignOrZero` which wraps `getKnownSign` but also tries `SLE` if the `SLT` analysis isn't fruitful? Then you could just replace the function here and we wouldn't need to duplicate so much codes.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156499/new/
https://reviews.llvm.org/D156499
More information about the llvm-commits
mailing list