[llvm] 6063e3c - [ValueTracking] Implement `computeKnownBits` for `llvm.vector.reduce.{or,and}`
Noah Goldstein via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 14 20:49:19 PDT 2024
Author: Noah Goldstein
Date: 2024-04-14T22:49:05-05:00
New Revision: 6063e3c40867e9b9865aee326ff36cb2ebbcf939
URL: https://github.com/llvm/llvm-project/commit/6063e3c40867e9b9865aee326ff36cb2ebbcf939
DIFF: https://github.com/llvm/llvm-project/commit/6063e3c40867e9b9865aee326ff36cb2ebbcf939.diff
LOG: [ValueTracking] Implement `computeKnownBits` for `llvm.vector.reduce.{or,and}`
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstCombine/known-bits.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index b83e7e6769c200..359a9dc7907b7e 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -1624,8 +1624,10 @@ static void computeKnownBitsFromOperator(const Operator *I,
computeKnownBits(I->getOperand(1), Known2, Depth + 1, Q);
Known = KnownBits::ssub_sat(Known, Known2);
break;
- // for min/max reduce, any bit common to each element in the input vec
- // is set in the output.
+ // for min/max/and/or reduce, any bit common to each element in the
+ // input vec is set in the output.
+ case Intrinsic::vector_reduce_and:
+ case Intrinsic::vector_reduce_or:
case Intrinsic::vector_reduce_umax:
case Intrinsic::vector_reduce_umin:
case Intrinsic::vector_reduce_smax:
diff --git a/llvm/test/Transforms/InstCombine/known-bits.ll b/llvm/test/Transforms/InstCombine/known-bits.ll
index cdc3e991a3fb5a..ce415dd406c05c 100644
--- a/llvm/test/Transforms/InstCombine/known-bits.ll
+++ b/llvm/test/Transforms/InstCombine/known-bits.ll
@@ -1197,10 +1197,7 @@ define i1 @extract_value_smul_fail(i8 %xx, i8 %yy) {
define i8 @known_reduce_or(<2 x i8> %xx) {
; CHECK-LABEL: @known_reduce_or(
-; CHECK-NEXT: [[X:%.*]] = or <2 x i8> [[XX:%.*]], <i8 5, i8 3>
-; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.or.v2i8(<2 x i8> [[X]])
-; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 1
-; CHECK-NEXT: ret i8 [[R]]
+; CHECK-NEXT: ret i8 1
;
%x = or <2 x i8> %xx, <i8 5, i8 3>
%v = call i8 @llvm.vector.reduce.or(<2 x i8> %x)
@@ -1223,10 +1220,7 @@ define i8 @known_reduce_or_fail(<2 x i8> %xx) {
define i8 @known_reduce_and(<2 x i8> %xx) {
; CHECK-LABEL: @known_reduce_and(
-; CHECK-NEXT: [[X:%.*]] = or <2 x i8> [[XX:%.*]], <i8 5, i8 3>
-; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.or.v2i8(<2 x i8> [[X]])
-; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 1
-; CHECK-NEXT: ret i8 [[R]]
+; CHECK-NEXT: ret i8 1
;
%x = or <2 x i8> %xx, <i8 5, i8 3>
%v = call i8 @llvm.vector.reduce.or(<2 x i8> %x)
More information about the llvm-commits
mailing list