From 7f82f108c2ec08636224dd0b58fe7e9021852002 Mon Sep 17 00:00:00 2001 From: Noah Goldstein Date: Thu, 11 May 2023 23:12:54 -0500 Subject: [PATCH] [ValueTracking] Add tests for deducing `X * Y != 0` if `LSB(X) * LSB(Y) != 0`; NFC Differential Revision: https://reviews.llvm.org/D150424 --- llvm/test/Analysis/ValueTracking/known-non-zero.ll | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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 +} -- 2.7.4