Skip to content

Commit 7e0b154

Browse files
goldsteinnaniplcc
authored andcommitted
[ValueTracking] Implement isKnownNonZero for llvm.vector.reduce.or
Closes llvm#88320
1 parent f9a8490 commit 7e0b154

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2918,7 +2918,8 @@ static bool isKnownNonZeroFromOperator(const Operator *I,
29182918
return isNonZeroAdd(DemandedElts, Depth, Q, BitWidth,
29192919
II->getArgOperand(0), II->getArgOperand(1),
29202920
/*NSW=*/true, /* NUW=*/false);
2921-
// umin/smin/smax/smin of all non-zero elements is always non-zero.
2921+
// umin/smin/smax/smin/or of all non-zero elements is always non-zero.
2922+
case Intrinsic::vector_reduce_or:
29222923
case Intrinsic::vector_reduce_umax:
29232924
case Intrinsic::vector_reduce_umin:
29242925
case Intrinsic::vector_reduce_smax:

llvm/test/Transforms/InstSimplify/known-non-zero.ll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,7 @@ define <2 x i1> @insert_nonzero_any_idx_fail(<2 x i8> %xx, i8 %yy, i32 %idx) {
380380

381381
define i1 @nonzero_reduce_or(<2 x i8> %xx) {
382382
; CHECK-LABEL: @nonzero_reduce_or(
383-
; CHECK-NEXT: [[X:%.*]] = add nuw <2 x i8> [[XX:%.*]], <i8 1, i8 1>
384-
; CHECK-NEXT: [[V:%.*]] = call i8 @llvm.vector.reduce.or.v2i8(<2 x i8> [[X]])
385-
; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], 0
386-
; CHECK-NEXT: ret i1 [[R]]
383+
; CHECK-NEXT: ret i1 false
387384
;
388385
%x = add nuw <2 x i8> %xx, <i8 1, i8 1>
389386
%v = call i8 @llvm.vector.reduce.or(<2 x i8> %x)

0 commit comments

Comments
 (0)