[llvm-branch-commits] [llvm] 5c6dc7b - [NFC][Tests] Added one additional test case for NaryRessociation pass.

Evgeniy Brevnov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Dec 3 04:15:46 PST 2020


Author: Evgeniy Brevnov
Date: 2020-12-03T19:11:08+07:00
New Revision: 5c6dc7b882be747746211c021e9ebc41e8ceb2b0

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

LOG: [NFC][Tests] Added one additional test case for NaryRessociation pass.

New tes cases added. Change var names to avoid the following warning from  update_test_checks.py:

WARNING: Change IR value name 'tmp5' to prevent possible conflict with scripted FileCheck name.

Reviewed By: ebrevnov

Differential Revision: https://reviews.llvm.org/D92566

Added: 
    

Modified: 
    llvm/test/Transforms/NaryReassociate/pr24301.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/NaryReassociate/pr24301.ll b/llvm/test/Transforms/NaryReassociate/pr24301.ll
index 2bcbc937d18f..2eef29cb19a1 100644
--- a/llvm/test/Transforms/NaryReassociate/pr24301.ll
+++ b/llvm/test/Transforms/NaryReassociate/pr24301.ll
@@ -2,21 +2,42 @@
 ; RUN: opt < %s -nary-reassociate -S | FileCheck %s
 ; RUN: opt < %s -passes='nary-reassociate' -S | FileCheck %s
 
-define i32 @foo(i32 %tmp4) {
+define i32 @foo(i32 %t4) {
 ; CHECK-LABEL: @foo(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[TMP5:%.*]] = add i32 [[TMP4:%.*]], 8
-; CHECK-NEXT:    [[TMP14:%.*]] = add i32 [[TMP5]], -128
-; CHECK-NEXT:    [[TMP21:%.*]] = add i32 119, [[TMP4]]
-; CHECK-NEXT:    [[TMP23:%.*]] = add i32 [[TMP21]], -128
-; CHECK-NEXT:    ret i32 [[TMP23]]
+; CHECK-NEXT:    [[T5:%.*]] = add i32 [[T4:%.*]], 8
+; CHECK-NEXT:    [[T14:%.*]] = add i32 [[T5]], -128
+; CHECK-NEXT:    [[T21:%.*]] = add i32 119, [[T4]]
+; CHECK-NEXT:    [[T23:%.*]] = add i32 [[T21]], -128
+; CHECK-NEXT:    ret i32 [[T23]]
 ;
 entry:
-  %tmp5 = add i32 %tmp4, 8
-  %tmp13 = add i32 %tmp4, -128  ; deleted
-  %tmp14 = add i32 %tmp13, 8    ; => %tmp5 + -128
-  %tmp21 = add i32 119, %tmp4
-  ; do not rewrite %tmp23 against %tmp13 because %tmp13 is already deleted
-  %tmp23 = add i32 %tmp21, -128
-  ret i32 %tmp23
+  %t5 = add i32 %t4, 8
+  %t13 = add i32 %t4, -128  ; deleted
+  %t14 = add i32 %t13, 8    ; => %t5 + -128
+  %t21 = add i32 119, %t4
+  ; do not rewrite %t23 against %t13 because %t13 is already deleted
+  %t23 = add i32 %t21, -128
+  ret i32 %t23
+}
+
+; This is essentially the same test as the previous one but intermidiate result (t14) has a use.
+define i32 @foo2(i32 %t4) {
+; CHECK-LABEL: @foo2(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[T5:%.*]] = add i32 [[T4:%.*]], 8
+; CHECK-NEXT:    [[T14:%.*]] = add i32 [[T5]], -128
+; CHECK-NEXT:    [[T21:%.*]] = add i32 119, [[T4]]
+; CHECK-NEXT:    [[T23:%.*]] = add i32 [[T21]], -128
+; CHECK-NEXT:    [[RES:%.*]] = add i32 [[T14]], [[T23]]
+; CHECK-NEXT:    ret i32 [[RES]]
+;
+entry:
+  %t5 = add i32 %t4, 8
+  %t13 = add i32 %t4, -128  ; deleted
+  %t14 = add i32 %t13, 8    ; => %t5 + -128
+  %t21 = add i32 119, %t4
+  %t23 = add i32 %t21, -128
+  %res = add i32 %t14, %t23
+  ret i32 %res
 }


        


More information about the llvm-branch-commits mailing list