[llvm] a49a3a3 - [LSR] Add test for PR46943 (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 23 04:53:24 PST 2021
Author: Nikita Popov
Date: 2021-01-23T13:53:09+01:00
New Revision: a49a3a3ed568244b12d6f553240485696e084f4a
URL: https://github.com/llvm/llvm-project/commit/a49a3a3ed568244b12d6f553240485696e084f4a
DIFF: https://github.com/llvm/llvm-project/commit/a49a3a3ed568244b12d6f553240485696e084f4a.diff
LOG: [LSR] Add test for PR46943 (NFC)
LSR should be dropping nowrap flags when adding new postinc users.
Added:
llvm/test/Transforms/LoopStrengthReduce/X86/pr46943.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/LoopStrengthReduce/X86/pr46943.ll b/llvm/test/Transforms/LoopStrengthReduce/X86/pr46943.ll
new file mode 100644
index 000000000000..e8f192d3c488
--- /dev/null
+++ b/llvm/test/Transforms/LoopStrengthReduce/X86/pr46943.ll
@@ -0,0 +1,95 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -loop-reduce < %s | FileCheck %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @use(i8 zeroext)
+declare void @use_p(i8*)
+
+define i8 @drop_nuw() {
+; CHECK-LABEL: @drop_nuw(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[IV:%.*]] = phi i8 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT: call void @use(i8 [[IV]])
+; CHECK-NEXT: [[IV_NEXT]] = add nuw i8 [[IV]], 1
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[IV_NEXT]], 0
+; CHECK-NEXT: br i1 [[CMP]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK: exit:
+; CHECK-NEXT: [[TMP0:%.*]] = add i8 [[IV_NEXT]], -1
+; CHECK-NEXT: ret i8 [[TMP0]]
+;
+entry:
+ br label %loop
+
+loop:
+ %iv = phi i8 [ 0, %entry ], [ %iv.next, %loop ]
+ call void @use(i8 %iv)
+
+ %iv.next = add nuw i8 %iv, 1
+ %cmp = icmp eq i8 %iv, -1
+ br i1 %cmp, label %exit, label %loop
+
+exit:
+ ret i8 %iv
+}
+
+define i8 @drop_nsw() {
+; CHECK-LABEL: @drop_nsw(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[IV:%.*]] = phi i8 [ 127, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT: call void @use(i8 [[IV]])
+; CHECK-NEXT: [[IV_NEXT]] = add nsw i8 [[IV]], -1
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[IV_NEXT]], 127
+; CHECK-NEXT: br i1 [[CMP]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK: exit:
+; CHECK-NEXT: [[TMP0:%.*]] = add i8 [[IV_NEXT]], 1
+; CHECK-NEXT: ret i8 [[TMP0]]
+;
+entry:
+ br label %loop
+
+loop:
+ %iv = phi i8 [ 127, %entry ], [ %iv.next, %loop ]
+ call void @use(i8 %iv)
+
+ %iv.next = add nsw i8 %iv, -1
+ %cmp = icmp eq i8 %iv, -128
+ br i1 %cmp, label %exit, label %loop
+
+exit:
+ ret i8 %iv
+}
+
+define i8 @already_postinc() {
+; CHECK-LABEL: @already_postinc(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[IV:%.*]] = phi i8 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
+; CHECK-NEXT: call void @use(i8 [[IV]])
+; CHECK-NEXT: [[IV_NEXT]] = add nuw i8 [[IV]], 1
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[IV_NEXT]], -1
+; CHECK-NEXT: br i1 [[CMP]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK: exit:
+; CHECK-NEXT: [[TMP0:%.*]] = add i8 [[IV_NEXT]], -1
+; CHECK-NEXT: ret i8 [[TMP0]]
+;
+entry:
+ br label %loop
+
+loop:
+ %iv = phi i8 [ 0, %entry ], [ %iv.next, %loop ]
+ call void @use(i8 %iv)
+
+ %iv.next = add nuw i8 %iv, 1
+ %cmp = icmp eq i8 %iv.next, -1
+ br i1 %cmp, label %exit, label %loop
+
+exit:
+ ret i8 %iv
+}
More information about the llvm-commits
mailing list