[llvm] 4b626dd - [NewGVN] Separate passing assume tests (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 12:07:15 PDT 2020


Author: Nikita Popov
Date: 2020-07-13T21:07:03+02:00
New Revision: 4b626dd94944d60751af62d65a2692698520fcc2

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

LOG: [NewGVN] Separate passing assume tests (NFC)

Result might not be exactly the same as under GVN, but all the
desired transforms are made.

Added: 
    llvm/test/Transforms/NewGVN/assume-equal.ll

Modified: 
    llvm/test/Transforms/NewGVN/assume-equal-xfail.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/NewGVN/assume-equal-xfail.ll b/llvm/test/Transforms/NewGVN/assume-equal-xfail.ll
index 7e009192064a..7da17441d078 100644
--- a/llvm/test/Transforms/NewGVN/assume-equal-xfail.ll
+++ b/llvm/test/Transforms/NewGVN/assume-equal-xfail.ll
@@ -154,117 +154,6 @@ entry:
   ret float %0
 }
 
-; CHECK-LABEL: define float @_Z1if(float %p)
-define float @_Z1if(float %p) {
-entry:
-  %p.addr = alloca float, align 4
-  store float %p, float* %p.addr, align 4
-  
-  %0 = load float, float* %p.addr, align 4
-  %cmp = fcmp ueq float %0, 3.000000e+00 ; no nnan flag - can't propagate
-  call void @llvm.assume(i1 %cmp)
-  
-  ; CHECK-NOT: ret float 3.000000e+00
-  ret float %0
-}
-
-; This test checks if constant propagation works for multiple node edges
-; CHECK-LABEL: define i32 @_Z1ii(i32 %p)
-define i32 @_Z1ii(i32 %p) {
-entry:
-  %cmp = icmp eq i32 %p, 42
-  call void @llvm.assume(i1 %cmp)
-  
-  ; CHECK: br i1 true, label %bb2, label %bb2
-  br i1 %cmp, label %bb2, label %bb2
-bb2:
-  call void @llvm.assume(i1 true)
-  ; CHECK: br i1 true, label %bb2, label %bb2
-  br i1 %cmp, label %bb2, label %bb2
-  
-  ; CHECK: ret i32 42
-  ret i32 %p
-}
-
-; CHECK-LABEL: define i32 @_Z1ij(i32 %p)
-define i32 @_Z1ij(i32 %p) {
-entry:
-  %cmp = icmp eq i32 %p, 42
-  call void @llvm.assume(i1 %cmp)
-  
-  ; CHECK: br i1 true, label %bb2, label %bb2
-  br i1 %cmp, label %bb2, label %bb2
-bb2:
-   ; CHECK-NOT: %cmp2 = 
-  %cmp2 = icmp eq i32 %p, 42
-  ; CHECK-NOT: call void @llvm.assume(
-  call void @llvm.assume(i1 %cmp2)
-  
-  ; CHECK: br i1 true, label %bb2, label %bb2
-  br i1 %cmp, label %bb2, label %bb2
-  
-  ; CHECK: ret i32 42
-  ret i32 %p
-}
-
-; CHECK-LABEL: define i32 @_Z1ik(i32 %p)
-define i32 @_Z1ik(i32 %p) {
-entry:
-  %cmp = icmp eq i32 %p, 42
-  call void @llvm.assume(i1 %cmp)
-  
-  ; CHECK: br i1 true, label %bb2, label %bb3
-  br i1 %cmp, label %bb2, label %bb3
-bb2:
-  ; CHECK-NOT: %cmp3 = 
-  %cmp3 = icmp eq i32 %p, 43
-  ; CHECK: store i8 undef, i8* null
-  call void @llvm.assume(i1 %cmp3)
-  ret i32 15
-bb3:
-  ret i32 17
-}
-
-; This test checks if GVN can do the constant propagation correctly
-; when there are multiple uses of the same assume value in the 
-; basic block that has a loop back-edge pointing to itself.
-;
-; CHECK-LABEL: define i32 @_Z1il(i32 %val, i1 %k)
-define i32 @_Z1il(i32 %val, i1 %k) {
-  br label %next
-
-next:
-; CHECK: tail call void @llvm.assume(i1 %k)
-; CHECK-NEXT: %cmp = icmp eq i32 %val, 50
-  tail call void @llvm.assume(i1 %k)
-  tail call void @llvm.assume(i1 %k)
-  %cmp = icmp eq i32 %val, 50
-  br i1 %cmp, label %next, label %meh
-
-meh:
-  ret i32 0 
-}
-
-; This test checks if GVN can prevent the constant propagation correctly
-; in the successor blocks that are not dominated by the basic block
-; with the assume instruction.
-;
-; CHECK-LABEL: define i1 @_z1im(i32 %val, i1 %k, i1 %j)
-define i1 @_z1im(i32 %val, i1 %k, i1 %j) {
-  br i1 %j, label %next, label %meh
-
-next:
-; CHECK: tail call void @llvm.assume(i1 %k)
-; CHECK-NEXT: br label %meh
-  tail call void @llvm.assume(i1 %k)
-  tail call void @llvm.assume(i1 %k)
-  br label %meh
-
-meh:
-; CHECK: ret i1 %k
-  ret i1 %k
-}
-
 declare noalias i8* @_Znwm(i64)
 declare void @_ZN1AC1Ev(%struct.A*)
 declare void @llvm.assume(i1)

diff  --git a/llvm/test/Transforms/NewGVN/assume-equal.ll b/llvm/test/Transforms/NewGVN/assume-equal.ll
new file mode 100644
index 000000000000..a20075665882
--- /dev/null
+++ b/llvm/test/Transforms/NewGVN/assume-equal.ll
@@ -0,0 +1,151 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -newgvn -S | FileCheck %s
+
+define float @_Z1if(float %p) {
+; CHECK-LABEL: @_Z1if(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[P_ADDR:%.*]] = alloca float, align 4
+; CHECK-NEXT:    store float [[P:%.*]], float* [[P_ADDR]], align 4
+; CHECK-NEXT:    [[CMP:%.*]] = fcmp ueq float [[P]], 3.000000e+00
+; CHECK-NEXT:    call void @llvm.assume(i1 true)
+; CHECK-NEXT:    ret float [[P]]
+;
+entry:
+  %p.addr = alloca float, align 4
+  store float %p, float* %p.addr, align 4
+
+  %0 = load float, float* %p.addr, align 4
+  %cmp = fcmp ueq float %0, 3.000000e+00 ; no nnan flag - can't propagate
+  call void @llvm.assume(i1 %cmp)
+
+  ret float %0
+}
+
+; This test checks if constant propagation works for multiple node edges
+define i32 @_Z1ii(i32 %p) {
+; CHECK-LABEL: @_Z1ii(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i32 [[P:%.*]], 42
+; CHECK-NEXT:    call void @llvm.assume(i1 true)
+; CHECK-NEXT:    br i1 true, label [[BB2:%.*]], label [[BB2]]
+; CHECK:       bb2:
+; CHECK-NEXT:    br i1 true, label [[BB2]], label [[BB2]]
+; CHECK:       0:
+; CHECK-NEXT:    store i8 undef, i8* null, align 1
+; CHECK-NEXT:    ret i32 [[P]]
+;
+entry:
+  %cmp = icmp eq i32 %p, 42
+  call void @llvm.assume(i1 %cmp)
+
+  br i1 %cmp, label %bb2, label %bb2
+bb2:
+  call void @llvm.assume(i1 true)
+  br i1 %cmp, label %bb2, label %bb2
+
+  ret i32 %p
+}
+
+define i32 @_Z1ij(i32 %p) {
+; CHECK-LABEL: @_Z1ij(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i32 [[P:%.*]], 42
+; CHECK-NEXT:    call void @llvm.assume(i1 true)
+; CHECK-NEXT:    br i1 true, label [[BB2:%.*]], label [[BB2]]
+; CHECK:       bb2:
+; CHECK-NEXT:    call void @llvm.assume(i1 true)
+; CHECK-NEXT:    br i1 true, label [[TMP0:%.*]], label [[BB2]]
+; CHECK:       0:
+; CHECK-NEXT:    ret i32 42
+;
+entry:
+  %cmp = icmp eq i32 %p, 42
+  call void @llvm.assume(i1 %cmp)
+
+  br i1 %cmp, label %bb2, label %bb2
+bb2:
+  %cmp2 = icmp eq i32 %p, 42
+  call void @llvm.assume(i1 %cmp2)
+
+  br i1 %cmp, label %0, label %bb2
+
+  ret i32 %p
+}
+
+define i32 @_Z1ik(i32 %p) {
+; CHECK-LABEL: @_Z1ik(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i32 [[P:%.*]], 42
+; CHECK-NEXT:    call void @llvm.assume(i1 true)
+; CHECK-NEXT:    br i1 true, label [[BB2:%.*]], label [[BB3:%.*]]
+; CHECK:       bb2:
+; CHECK-NEXT:    call void @llvm.assume(i1 true)
+; CHECK-NEXT:    ret i32 15
+; CHECK:       bb3:
+; CHECK-NEXT:    store i8 undef, i8* null, align 1
+; CHECK-NEXT:    ret i32 17
+;
+entry:
+  %cmp = icmp eq i32 %p, 42
+  call void @llvm.assume(i1 %cmp)
+
+  br i1 %cmp, label %bb2, label %bb3
+bb2:
+  %cmp3 = icmp eq i32 %p, 43
+  call void @llvm.assume(i1 %cmp3)
+  ret i32 15
+bb3:
+  ret i32 17
+}
+
+; This test checks if GVN can do the constant propagation correctly
+; when there are multiple uses of the same assume value in the
+; basic block that has a loop back-edge pointing to itself.
+define i32 @_Z1il(i32 %val, i1 %k) {
+; CHECK-LABEL: @_Z1il(
+; CHECK-NEXT:    br label [[NEXT:%.*]]
+; CHECK:       next:
+; CHECK-NEXT:    tail call void @llvm.assume(i1 [[K:%.*]])
+; CHECK-NEXT:    tail call void @llvm.assume(i1 [[K]])
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i32 [[VAL:%.*]], 50
+; CHECK-NEXT:    br i1 [[CMP]], label [[NEXT]], label [[MEH:%.*]]
+; CHECK:       meh:
+; CHECK-NEXT:    ret i32 0
+;
+  br label %next
+
+next:
+  tail call void @llvm.assume(i1 %k)
+  tail call void @llvm.assume(i1 %k)
+  %cmp = icmp eq i32 %val, 50
+  br i1 %cmp, label %next, label %meh
+
+meh:
+  ret i32 0
+}
+
+; This test checks if GVN can prevent the constant propagation correctly
+; in the successor blocks that are not dominated by the basic block
+; with the assume instruction.
+define i1 @_z1im(i32 %val, i1 %k, i1 %j) {
+; CHECK-LABEL: @_z1im(
+; CHECK-NEXT:    br i1 [[J:%.*]], label [[NEXT:%.*]], label [[MEH:%.*]]
+; CHECK:       next:
+; CHECK-NEXT:    tail call void @llvm.assume(i1 [[K:%.*]])
+; CHECK-NEXT:    tail call void @llvm.assume(i1 [[K]])
+; CHECK-NEXT:    br label [[MEH]]
+; CHECK:       meh:
+; CHECK-NEXT:    ret i1 [[K]]
+;
+  br i1 %j, label %next, label %meh
+
+next:
+  tail call void @llvm.assume(i1 %k)
+  tail call void @llvm.assume(i1 %k)
+  br label %meh
+
+meh:
+  ret i1 %k
+}
+
+declare void @llvm.assume(i1)


        


More information about the llvm-commits mailing list