[llvm] 8c13099 - Revert "[InstCombine] Support inverting lshr with non-negative operand"
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 1 07:05:29 PST 2023
Author: Nikita Popov
Date: 2023-12-01T16:05:17+01:00
New Revision: 8c130996c03f6c5993a0989a5c6fa95d1437995a
URL: https://github.com/llvm/llvm-project/commit/8c130996c03f6c5993a0989a5c6fa95d1437995a
DIFF: https://github.com/llvm/llvm-project/commit/8c130996c03f6c5993a0989a5c6fa95d1437995a.diff
LOG: Revert "[InstCombine] Support inverting lshr with non-negative operand"
This reverts commit b92693ac6afc522ea56bede0b9805ca7c138754c.
I've made a silly typo in the condition. Will reapply the corrected
version.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/free-inversion.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index a2fadbd6999c5b1..26fdef672506a68 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2181,16 +2181,6 @@ Value *InstCombiner::getFreelyInvertedImpl(Value *V, bool WillInvertAllUses,
return nullptr;
}
- // Treat lshr with non-negative operand as ashr.
- if (match(V, m_LShr(m_Value(A), m_Value(B))) &&
- isKnownNonNegative(V, SQ.getWithInstruction(cast<Instruction>(V)),
- Depth)) {
- if (auto *AV = getFreelyInvertedImpl(A, A->hasOneUse(), Builder,
- DoesConsume, Depth))
- return Builder ? Builder->CreateAShr(AV, B) : NonNull;
- return nullptr;
- }
-
Value *Cond;
// LogicOps are special in that we canonicalize them at the cost of an
// instruction.
diff --git a/llvm/test/Transforms/InstCombine/free-inversion.ll b/llvm/test/Transforms/InstCombine/free-inversion.ll
index 8d5b1936f95637a..c16310cf09631c5 100644
--- a/llvm/test/Transforms/InstCombine/free-inversion.ll
+++ b/llvm/test/Transforms/InstCombine/free-inversion.ll
@@ -499,7 +499,9 @@ define i8 @lshr_nneg(i8 %x, i8 %y) {
; CHECK-LABEL: @lshr_nneg(
; CHECK-NEXT: [[NEG:%.*]] = icmp slt i8 [[X:%.*]], 0
; CHECK-NEXT: call void @llvm.assume(i1 [[NEG]])
-; CHECK-NEXT: [[SHR_NOT:%.*]] = ashr i8 [[X]], [[Y:%.*]]
+; CHECK-NEXT: [[X_NOT:%.*]] = xor i8 [[X]], -1
+; CHECK-NEXT: [[SHR:%.*]] = lshr i8 [[X_NOT]], [[Y:%.*]]
+; CHECK-NEXT: [[SHR_NOT:%.*]] = xor i8 [[SHR]], -1
; CHECK-NEXT: ret i8 [[SHR_NOT]]
;
%neg = icmp slt i8 %x, 0
More information about the llvm-commits
mailing list