[llvm] 1623292 - [InstCombine] Add test for #74242 (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 4 01:32:46 PST 2023


Author: Nikita Popov
Date: 2023-12-04T10:32:20+01:00
New Revision: 16232927062ec56d41911b1538a7887a6ee023a1

URL: https://github.com/llvm/llvm-project/commit/16232927062ec56d41911b1538a7887a6ee023a1
DIFF: https://github.com/llvm/llvm-project/commit/16232927062ec56d41911b1538a7887a6ee023a1.diff

LOG: [InstCombine] Add test for #74242 (NFC)

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/udiv-simplify.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/udiv-simplify.ll b/llvm/test/Transforms/InstCombine/udiv-simplify.ll
index dd2dc28d4bcc5..cb813e87249e2 100644
--- a/llvm/test/Transforms/InstCombine/udiv-simplify.ll
+++ b/llvm/test/Transforms/InstCombine/udiv-simplify.ll
@@ -164,3 +164,29 @@ define <vscale x 1 x i32> @udiv_demanded3(<vscale x 1 x i32> %a) {
   %u = udiv <vscale x 1 x i32> %o, shufflevector (<vscale x 1 x i32> insertelement (<vscale x 1 x i32> poison, i32 12, i32 0), <vscale x 1 x i32> poison, <vscale x 1 x i32> zeroinitializer)
   ret <vscale x 1 x i32> %u
 }
+
+; PR74242
+define i32 @div_by_zero_or_one_from_dom_cond(i32 %a, i32 %b) {
+; CHECK-LABEL: @div_by_zero_or_one_from_dom_cond(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i32 [[A:%.*]], 1
+; CHECK-NEXT:    br i1 [[CMP]], label [[JOIN:%.*]], label [[ZERO_OR_ONE:%.*]]
+; CHECK:       zero_or_one:
+; CHECK-NEXT:    [[DIV:%.*]] = udiv i32 [[B:%.*]], [[A]]
+; CHECK-NEXT:    br label [[JOIN]]
+; CHECK:       join:
+; CHECK-NEXT:    [[RES:%.*]] = phi i32 [ [[DIV]], [[ZERO_OR_ONE]] ], [ [[B]], [[ENTRY:%.*]] ]
+; CHECK-NEXT:    ret i32 [[RES]]
+;
+entry:
+  %cmp = icmp ugt i32 %a, 1
+  br i1 %cmp, label %join, label %zero_or_one
+
+zero_or_one:
+  %div = udiv i32 %b, %a
+  br label %join
+
+join:
+  %res = phi i32 [ %div, %zero_or_one ], [ %b, %entry ]
+  ret i32 %res
+}


        


More information about the llvm-commits mailing list