From 38c1ff89eee769d19ae07b585530f8edd69e124a Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 21 Dec 2023 15:36:07 +0100 Subject: [PATCH] [CVP] Add additional tests for undef check (NFC) --- .../CorrelatedValuePropagation/cond-at-use.ll | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/llvm/test/Transforms/CorrelatedValuePropagation/cond-at-use.ll b/llvm/test/Transforms/CorrelatedValuePropagation/cond-at-use.ll index 7ec1028d65e0e9..546baf086cdbb0 100644 --- a/llvm/test/Transforms/CorrelatedValuePropagation/cond-at-use.ll +++ b/llvm/test/Transforms/CorrelatedValuePropagation/cond-at-use.ll @@ -567,3 +567,33 @@ define i16 @cond_value_may_not_well_defined(i16 %x) { %sel = select i1 %cmp, i16 %and, i16 24 ret i16 %sel } + +define i16 @and_elide_poison_flags(i16 noundef %a) { +; CHECK-LABEL: @and_elide_poison_flags( +; CHECK-NEXT: [[X:%.*]] = add nuw i16 [[A:%.*]], 1 +; CHECK-NEXT: [[AND:%.*]] = and i16 [[X]], 7 +; CHECK-NEXT: [[CMP:%.*]] = icmp ult i16 [[X]], 8 +; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i16 [[AND]], i16 24 +; CHECK-NEXT: ret i16 [[SEL]] +; + %x = add nuw i16 %a, 1 + %and = and i16 %x, 7 + %cmp = icmp ult i16 %x, 8 + %sel = select i1 %cmp, i16 %and, i16 24 + ret i16 %sel +} + +define i16 @and_elide_poison_flags_missing_noundef(i16 %a) { +; CHECK-LABEL: @and_elide_poison_flags_missing_noundef( +; CHECK-NEXT: [[X:%.*]] = add nuw i16 [[A:%.*]], 1 +; CHECK-NEXT: [[AND:%.*]] = and i16 [[X]], 7 +; CHECK-NEXT: [[CMP:%.*]] = icmp ult i16 [[X]], 8 +; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i16 [[AND]], i16 24 +; CHECK-NEXT: ret i16 [[SEL]] +; + %x = add nuw i16 %a, 1 + %and = and i16 %x, 7 + %cmp = icmp ult i16 %x, 8 + %sel = select i1 %cmp, i16 %and, i16 24 + ret i16 %sel +}