From: Noah Goldstein Date: Fri, 12 May 2023 04:12:54 +0000 (-0500) Subject: [ValueTracking] Add tests for deducing `X * Y != 0` if `LSB(X) * LSB(Y) != 0`; NFC X-Git-Tag: upstream/17.0.6~8242 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7f82f108c2ec08636224dd0b58fe7e9021852002;p=platform%2Fupstream%2Fllvm.git [ValueTracking] Add tests for deducing `X * Y != 0` if `LSB(X) * LSB(Y) != 0`; NFC Differential Revision: https://reviews.llvm.org/D150424 --- diff --git a/llvm/test/Analysis/ValueTracking/known-non-zero.ll b/llvm/test/Analysis/ValueTracking/known-non-zero.ll index 6b7ecdc..fca016b 100644 --- a/llvm/test/Analysis/ValueTracking/known-non-zero.ll +++ b/llvm/test/Analysis/ValueTracking/known-non-zero.ll @@ -1096,3 +1096,33 @@ define i1 @smax_nonzero_pos_arg_fail_nonstrict_pos(i8 %xx, i8 %yy, i8 %ind) { %r = icmp eq i8 %z, 0 ret i1 %r } + +define i1 @mul_nonzero_contains_nonzero_mul(i8 %x, i8 %y) { +; CHECK-LABEL: @mul_nonzero_contains_nonzero_mul( +; CHECK-NEXT: [[XX:%.*]] = or i8 [[X:%.*]], 16 +; CHECK-NEXT: [[YY:%.*]] = or i8 [[Y:%.*]], 8 +; CHECK-NEXT: [[XY:%.*]] = mul i8 [[XX]], [[YY]] +; CHECK-NEXT: [[NZ:%.*]] = icmp ne i8 [[XY]], 0 +; CHECK-NEXT: ret i1 [[NZ]] +; + %xx = or i8 %x, 16 + %yy = or i8 %y, 8 + %xy = mul i8 %xx, %yy + %nz = icmp ne i8 %xy, 0 + ret i1 %nz +} + +define i1 @src_mul_maybe_zero_no_nonzero_mul(i8 %x, i8 %y) { +; CHECK-LABEL: @src_mul_maybe_zero_no_nonzero_mul( +; CHECK-NEXT: [[XX:%.*]] = or i8 [[X:%.*]], 96 +; CHECK-NEXT: [[YY:%.*]] = or i8 [[Y:%.*]], 8 +; CHECK-NEXT: [[XY:%.*]] = mul i8 [[XX]], [[YY]] +; CHECK-NEXT: [[NZ:%.*]] = icmp ne i8 [[XY]], 0 +; CHECK-NEXT: ret i1 [[NZ]] +; + %xx = or i8 %x, 96 + %yy = or i8 %y, 8 + %xy = mul i8 %xx, %yy + %nz = icmp ne i8 %xy, 0 + ret i1 %nz +}