From: Nikita Popov Date: Sat, 22 Jun 2019 09:57:59 +0000 (+0000) Subject: [LFTR] Add tests for PR41998; NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=761589542dea9daae2fbfbce0763e26551bea906;p=llvm [LFTR] Add tests for PR41998; NFC The limit for the pointer case is incorrect. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364128 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/IndVarSimplify/lftr-pr41998.ll b/test/Transforms/IndVarSimplify/lftr-pr41998.ll new file mode 100644 index 00000000000..1f04a4b56a4 --- /dev/null +++ b/test/Transforms/IndVarSimplify/lftr-pr41998.ll @@ -0,0 +1,73 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -indvars -S | FileCheck %s + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" + +define void @test_int(i32 %start, i32* %p) { +; CHECK-LABEL: @test_int( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[TMP0:%.*]] = trunc i32 [[START:%.*]] to i3 +; CHECK-NEXT: [[TMP1:%.*]] = sub i3 0, [[TMP0]] +; CHECK-NEXT: br label [[LOOP:%.*]] +; CHECK: loop: +; CHECK-NEXT: [[I2:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[I2_INC:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[I2_INC]] = add nuw nsw i32 [[I2]], 1 +; CHECK-NEXT: store volatile i32 [[I2_INC]], i32* [[P:%.*]] +; CHECK-NEXT: [[LFTR_WIDEIV:%.*]] = trunc i32 [[I2_INC]] to i3 +; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i3 [[LFTR_WIDEIV]], [[TMP1]] +; CHECK-NEXT: br i1 [[EXITCOND]], label [[END:%.*]], label [[LOOP]] +; CHECK: end: +; CHECK-NEXT: ret void +; +entry: + br label %loop + +loop: + %i = phi i32 [ %start, %entry ], [ %i.inc, %loop ] + %i2 = phi i32 [ 0, %entry ], [ %i2.inc, %loop ] + %i.inc = add nuw i32 %i, 1 + %i2.inc = add nuw i32 %i2, 1 + store volatile i32 %i2.inc, i32* %p + %and = and i32 %i.inc, 7 + %cmp = icmp eq i32 %and, 0 + br i1 %cmp, label %end, label %loop + +end: + ret void +} + +@data = global [256 x i8] zeroinitializer + +define void @test_ptr(i32 %start) { +; CHECK-LABEL: @test_ptr( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[TMP0:%.*]] = trunc i32 [[START:%.*]] to i3 +; CHECK-NEXT: [[TMP1:%.*]] = sub i3 0, [[TMP0]] +; CHECK-NEXT: [[TMP2:%.*]] = zext i3 [[TMP1]] to i64 +; CHECK-NEXT: [[LFTR_LIMIT:%.*]] = getelementptr i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @data, i64 0, i64 0), i64 [[TMP2]] +; CHECK-NEXT: br label [[LOOP:%.*]] +; CHECK: loop: +; CHECK-NEXT: [[P:%.*]] = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @data, i64 0, i64 0), [[ENTRY:%.*]] ], [ [[P_INC:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[P_INC]] = getelementptr inbounds i8, i8* [[P]], i64 1 +; CHECK-NEXT: store volatile i8 0, i8* [[P_INC]] +; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i8* [[P_INC]], [[LFTR_LIMIT]] +; CHECK-NEXT: br i1 [[EXITCOND]], label [[END:%.*]], label [[LOOP]] +; CHECK: end: +; CHECK-NEXT: ret void +; +entry: + br label %loop + +loop: + %i = phi i32 [ %start, %entry ], [ %i.inc, %loop ] + %p = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @data, i64 0, i64 0), %entry ], [ %p.inc, %loop ] + %i.inc = add nuw i32 %i, 1 + %p.inc = getelementptr inbounds i8, i8* %p, i64 1 + store volatile i8 0, i8* %p.inc + %and = and i32 %i.inc, 7 + %cmp = icmp eq i32 %and, 0 + br i1 %cmp, label %end, label %loop + +end: + ret void +}