Skip to content

Commit 2490859

Browse files
committed
[ValueTracking] Implement computeKnownBits for llvm.vector.reduce.{or,and}
1 parent 9fe7625 commit 2490859

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,8 +1624,10 @@ static void computeKnownBitsFromOperator(const Operator *I,
16241624
computeKnownBits(I->getOperand(1), Known2, Depth + 1, Q);
16251625
Known = KnownBits::ssub_sat(Known, Known2);
16261626
break;
1627-
// for min/max reduce, any bit common to each element in the input vec
1628-
// is set in the output.
1627+
// for min/max/and/or reduce, any bit common to each element in the
1628+
// input vec is set in the output.
1629+
case Intrinsic::vector_reduce_and:
1630+
case Intrinsic::vector_reduce_or:
16291631
case Intrinsic::vector_reduce_umax:
16301632
case Intrinsic::vector_reduce_umin:
16311633
case Intrinsic::vector_reduce_smax:

llvm/test/Transforms/InstCombine/known-bits.ll

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,10 +1197,7 @@ define i1 @extract_value_smul_fail(i8 %xx, i8 %yy) {
11971197

11981198
define i8 @known_reduce_or(<2 x i8> %xx) {
11991199
; CHECK-LABEL: @known_reduce_or(
1200-
; CHECK-NEXT: [[X:%.*]] = or <2 x i8> [[XX:%.*]], <i8 5, i8 3>
1201-
; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.or.v2i8(<2 x i8> [[X]])
1202-
; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 1
1203-
; CHECK-NEXT: ret i8 [[R]]
1200+
; CHECK-NEXT: ret i8 1
12041201
;
12051202
%x = or <2 x i8> %xx, <i8 5, i8 3>
12061203
%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) {
12231220

12241221
define i8 @known_reduce_and(<2 x i8> %xx) {
12251222
; CHECK-LABEL: @known_reduce_and(
1226-
; CHECK-NEXT: [[X:%.*]] = or <2 x i8> [[XX:%.*]], <i8 5, i8 3>
1227-
; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.or.v2i8(<2 x i8> [[X]])
1228-
; CHECK-NEXT: [[R:%.*]] = and i8 [[V]], 1
1229-
; CHECK-NEXT: ret i8 [[R]]
1223+
; CHECK-NEXT: ret i8 1
12301224
;
12311225
%x = or <2 x i8> %xx, <i8 5, i8 3>
12321226
%v = call i8 @llvm.vector.reduce.or(<2 x i8> %x)

0 commit comments

Comments
 (0)