[llvm] ea21fa3 - [Precommit][RISCV] Test folding for RISCVISD::BR_CC node

Anton Afanasyev via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 21 03:20:43 PST 2022


Author: Elena Lepilkina
Date: 2022-12-21T14:19:49+03:00
New Revision: ea21fa3a5977e769a8ba8e7fb7e867dad9306efa

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

LOG: [Precommit][RISCV] Test folding for RISCVISD::BR_CC node

Precommit test for https://reviews.llvm.org/D140206

Added: 
    llvm/test/CodeGen/RISCV/branch_zero.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/RISCV/branch_zero.ll b/llvm/test/CodeGen/RISCV/branch_zero.ll
new file mode 100644
index 0000000000000..2d6a3c99966e5
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/branch_zero.ll
@@ -0,0 +1,87 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s
+
+define void @foo(i16 %finder_idx) {
+; CHECK-LABEL: foo:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:  .LBB0_1: # %for.body
+; CHECK-NEXT:    # =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:    slli a0, a0, 48
+; CHECK-NEXT:    srai a0, a0, 48
+; CHECK-NEXT:    bltz a0, .LBB0_4
+; CHECK-NEXT:  # %bb.2: # %while.cond.preheader.i
+; CHECK-NEXT:    # in Loop: Header=BB0_1 Depth=1
+; CHECK-NEXT:    li a0, 0
+; CHECK-NEXT:    bnez zero, .LBB0_1
+; CHECK-NEXT:  # %bb.3: # %while.body
+; CHECK-NEXT:  .LBB0_4: # %while.cond1.preheader.i
+entry:
+  br label %for.body
+
+for.body:
+  %info = phi i16 [ 0, %if.then ], [ %finder_idx, %entry ]
+  %cmp.i = icmp sgt i16 %info, -1
+  %tobool = icmp eq ptr poison, null
+  br i1 %cmp.i, label %while.cond.preheader.i, label %while.cond1.preheader.i
+
+while.cond1.preheader.i:
+  unreachable
+
+while.cond.preheader.i:
+  br label %exit
+
+exit:
+  br i1 %tobool, label %exit1, label %while.body
+
+while.body:
+  unreachable
+
+exit1:
+  br label %if.then
+
+if.then:
+  br label %for.body
+}
+
+define void @bar(i16 %finder_idx) {
+; CHECK-LABEL: bar:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:  .LBB1_1: # %for.body
+; CHECK-NEXT:    # =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:    slli a0, a0, 48
+; CHECK-NEXT:    srai a0, a0, 48
+; CHECK-NEXT:    bgez a0, .LBB1_4
+; CHECK-NEXT:  # %bb.2: # %while.cond.preheader.i
+; CHECK-NEXT:    # in Loop: Header=BB1_1 Depth=1
+; CHECK-NEXT:    li a0, 0
+; CHECK-NEXT:    bnez zero, .LBB1_1
+; CHECK-NEXT:  # %bb.3: # %while.body
+; CHECK-NEXT:  .LBB1_4: # %while.cond1.preheader.i
+entry:
+  br label %for.body
+
+for.body:
+  %info = phi i16 [ 0, %if.then ], [ %finder_idx, %entry ]
+  %cmp.i = icmp sle i16 %info, -1
+  %tobool = icmp eq ptr poison, null
+  br i1 %cmp.i, label %while.cond.preheader.i, label %while.cond1.preheader.i
+
+while.cond1.preheader.i:
+  unreachable
+
+while.cond.preheader.i:
+  br label %exit
+
+exit:
+  br i1 %tobool, label %exit1, label %while.body
+
+while.body:
+  unreachable
+
+exit1:
+  br label %if.then
+
+if.then:
+  br label %for.body
+}


        


More information about the llvm-commits mailing list