[PATCH] D145339: [InstCombine] Add transform `(icmp eq/ne bitreverse(x), C)` -> `(icmp eq/ne x, bitreverse(C))`
Noah Goldstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 6 18:31:21 PST 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe2079e896aa1: [InstCombine] Add transform `(icmp eq/ne bitreverse(x), C)` -> `(icmp eq/ne x… (authored by goldstein.w.n).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145339/new/
https://reviews.llvm.org/D145339
Files:
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/test/Transforms/InstCombine/cmp-intrinsic.ll
Index: llvm/test/Transforms/InstCombine/cmp-intrinsic.ll
===================================================================
--- llvm/test/Transforms/InstCombine/cmp-intrinsic.ll
+++ llvm/test/Transforms/InstCombine/cmp-intrinsic.ll
@@ -767,8 +767,7 @@
define i1 @bitreverse_ne_22(i8 %x) {
; CHECK-LABEL: @bitreverse_ne_22(
-; CHECK-NEXT: [[Y:%.*]] = call i8 @llvm.bitreverse.i8(i8 [[X:%.*]])
-; CHECK-NEXT: [[Z:%.*]] = icmp ne i8 [[Y]], 22
+; CHECK-NEXT: [[Z:%.*]] = icmp ne i8 [[X:%.*]], 104
; CHECK-NEXT: ret i1 [[Z]]
;
%y = call i8 @llvm.bitreverse.i8(i8 %x)
@@ -790,8 +789,7 @@
define <2 x i1> @bitreverse_vec_eq_2_2(<2 x i8> %x) {
; CHECK-LABEL: @bitreverse_vec_eq_2_2(
-; CHECK-NEXT: [[Y:%.*]] = call <2 x i8> @llvm.bitreverse.v2i8(<2 x i8> [[X:%.*]])
-; CHECK-NEXT: [[Z:%.*]] = icmp eq <2 x i8> [[Y]], <i8 2, i8 2>
+; CHECK-NEXT: [[Z:%.*]] = icmp eq <2 x i8> [[X:%.*]], <i8 64, i8 64>
; CHECK-NEXT: ret <2 x i1> [[Z]]
;
%y = call <2 x i8> @llvm.bitreverse.v2i8(<2 x i8> %x)
Index: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -3282,6 +3282,11 @@
return new ICmpInst(Pred, II->getArgOperand(0),
ConstantInt::get(Ty, C.byteSwap()));
+ case Intrinsic::bitreverse:
+ // bitreverse(A) == C -> A == bitreverse(C)
+ return new ICmpInst(Pred, II->getArgOperand(0),
+ ConstantInt::get(Ty, C.reverseBits()));
+
case Intrinsic::ctlz:
case Intrinsic::cttz: {
// ctz(A) == bitwidth(A) -> A == 0 and likewise for !=
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145339.502887.patch
Type: text/x-patch
Size: 1731 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230307/21ed9577/attachment.bin>
More information about the llvm-commits
mailing list