From 2eced313df3aebc54d39f42409966a945f15e085 Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Fri, 30 Aug 2024 11:43:23 +0100 Subject: [PATCH] test: re-org, clean up after invalid #96656 --- .../LoopAccessAnalysis/symbolic-stride.ll | 32 +++---- llvm/test/Transforms/LoopLoadElim/pr96656.ll | 87 ------------------ .../LoopLoadElim/unknown-stride-known-dep.ll | 91 +++++++++++++++++++ .../LoopVersioning/single-iteration.ll | 52 ++++++----- 4 files changed, 134 insertions(+), 128 deletions(-) delete mode 100644 llvm/test/Transforms/LoopLoadElim/pr96656.ll create mode 100644 llvm/test/Transforms/LoopLoadElim/unknown-stride-known-dep.ll diff --git a/llvm/test/Analysis/LoopAccessAnalysis/symbolic-stride.ll b/llvm/test/Analysis/LoopAccessAnalysis/symbolic-stride.ll index 0871ae84c37111..69949587b1df17 100644 --- a/llvm/test/Analysis/LoopAccessAnalysis/symbolic-stride.ll +++ b/llvm/test/Analysis/LoopAccessAnalysis/symbolic-stride.ll @@ -223,7 +223,7 @@ exit: ret void } -define double @single_iteration_unknown_stride(i32 %arg, ptr %arg1, i1 %arg2) { +define double @single_iteration_unknown_stride(i32 %x, ptr %y, i1 %cond) { ; CHECK-LABEL: 'single_iteration_unknown_stride' ; CHECK-NEXT: loop.body: ; CHECK-NEXT: Memory dependences are safe @@ -233,40 +233,40 @@ define double @single_iteration_unknown_stride(i32 %arg, ptr %arg1, i1 %arg2) { ; CHECK-EMPTY: ; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop. ; CHECK-NEXT: SCEV assumptions: -; CHECK-NEXT: Equal predicate: %arg == 1 +; CHECK-NEXT: Equal predicate: %x == 1 ; CHECK-EMPTY: ; CHECK-NEXT: Expressions re-written: ; CHECK-NEXT: [PSE] %gep10 = getelementptr double, ptr %gep8, i64 %mul: -; CHECK-NEXT: {(8 + %arg1),+,(8 * (sext i32 %arg to i64))}<%loop.body> -; CHECK-NEXT: --> {(8 + %arg1),+,8}<%loop.body> +; CHECK-NEXT: {(8 + %y),+,(8 * (sext i32 %x to i64))}<%loop.body> +; CHECK-NEXT: --> {(8 + %y),+,8}<%loop.body> ; entry: - br i1 %arg2, label %noloop.exit, label %loop.ph + br i1 %cond, label %noloop.exit, label %loop.ph loop.ph: ; preds = %entry - %sext7 = sext i32 %arg to i64 - %gep8 = getelementptr i8, ptr %arg1, i64 8 + %sext7 = sext i32 %x to i64 + %gep8 = getelementptr i8, ptr %y, i64 8 br label %loop.body loop.body: ; preds = %loop.body, %loop.ph - %phi = phi i64 [ 0, %loop.ph ], [ %add, %loop.body ] - %mul = mul i64 %phi, %sext7 + %iv = phi i64 [ 0, %loop.ph ], [ %iv.next, %loop.body ] + %mul = mul i64 %iv, %sext7 %gep10 = getelementptr double, ptr %gep8, i64 %mul %load11 = load double, ptr %gep10, align 8 - store double %load11, ptr %arg1, align 8 - %add = add i64 %phi, 1 - %icmp = icmp eq i64 %phi, 0 + store double %load11, ptr %y, align 8 + %iv.next = add i64 %iv, 1 + %icmp = icmp eq i64 %iv, 0 br i1 %icmp, label %loop.exit, label %loop.body noloop.exit: ; preds = %entry - %sext = sext i32 %arg to i64 - %gep = getelementptr double, ptr %arg1, i64 %sext + %sext = sext i32 %x to i64 + %gep = getelementptr double, ptr %y, i64 %sext %load5 = load double, ptr %gep, align 8 ret double %load5 loop.exit: ; preds = %loop.body - %sext2 = sext i32 %arg to i64 - %gep2 = getelementptr double, ptr %arg1, i64 %sext2 + %sext2 = sext i32 %x to i64 + %gep2 = getelementptr double, ptr %y, i64 %sext2 %load6 = load double, ptr %gep2, align 8 ret double %load6 } diff --git a/llvm/test/Transforms/LoopLoadElim/pr96656.ll b/llvm/test/Transforms/LoopLoadElim/pr96656.ll deleted file mode 100644 index c6b336c0db8d39..00000000000000 --- a/llvm/test/Transforms/LoopLoadElim/pr96656.ll +++ /dev/null @@ -1,87 +0,0 @@ -; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 -; RUN: opt -passes=loop-load-elim -S %s | FileCheck %s - -define void @single_iteration_versioning(ptr %arg, ptr %arg1, i1 %arg2) { -; CHECK-LABEL: define void @single_iteration_versioning( -; CHECK-SAME: ptr [[ARG:%.*]], ptr [[ARG1:%.*]], i1 [[ARG2:%.*]]) { -; CHECK-NEXT: [[ENTRY:.*:]] -; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr [[ARG]], align 4 -; CHECK-NEXT: br i1 [[ARG2]], label %[[NOLOOP_EXIT:.*]], label %[[LOOP_LVER_CHECK:.*]] -; CHECK: [[LOOP_LVER_CHECK]]: -; CHECK-NEXT: [[SEXT7:%.*]] = sext i32 [[LOAD]] to i64 -; CHECK-NEXT: [[GEP8:%.*]] = getelementptr i8, ptr [[ARG1]], i64 8 -; CHECK-NEXT: [[GEP9:%.*]] = getelementptr i8, ptr [[ARG1]], i64 16 -; CHECK-NEXT: [[IDENT_CHECK:%.*]] = icmp ne i32 [[LOAD]], 1 -; CHECK-NEXT: br i1 [[IDENT_CHECK]], label %[[LOOP_PH_LVER_ORIG:.*]], label %[[LOOP_PH:.*]] -; CHECK: [[LOOP_PH_LVER_ORIG]]: -; CHECK-NEXT: br label %[[LOOP_LVER_ORIG:.*]] -; CHECK: [[LOOP_LVER_ORIG]]: -; CHECK-NEXT: [[PHI:%.*]] = phi i64 [ 0, %[[LOOP_PH_LVER_ORIG]] ], [ [[ADD:%.*]], %[[LOOP_LVER_ORIG]] ] -; CHECK-NEXT: [[MUL:%.*]] = mul i64 [[PHI]], [[SEXT7]] -; CHECK-NEXT: [[GEP10:%.*]] = getelementptr double, ptr [[GEP8]], i64 [[MUL]] -; CHECK-NEXT: [[LOAD11:%.*]] = load double, ptr [[GEP10]], align 8 -; CHECK-NEXT: [[GEP13_LVER_ORIG:%.*]] = getelementptr double, ptr [[GEP9]], i64 [[MUL]] -; CHECK-NEXT: store double [[LOAD11]], ptr [[GEP13_LVER_ORIG]], align 8 -; CHECK-NEXT: [[ADD]] = add i64 [[PHI]], 1 -; CHECK-NEXT: [[ICMP_LVER_ORIG:%.*]] = icmp eq i64 [[PHI]], 1 -; CHECK-NEXT: br i1 [[ICMP_LVER_ORIG]], label %[[EXIT_LOOPEXIT_LOOPEXIT:.*]], label %[[LOOP_LVER_ORIG]] -; CHECK: [[LOOP_PH]]: -; CHECK-NEXT: [[LOAD_INITIAL:%.*]] = load double, ptr [[GEP8]], align 8 -; CHECK-NEXT: br label %[[LOOP:.*]] -; CHECK: [[LOOP]]: -; CHECK-NEXT: [[STORE_FORWARDED:%.*]] = phi double [ [[LOAD_INITIAL]], %[[LOOP_PH]] ], [ [[STORE_FORWARDED]], %[[LOOP]] ] -; CHECK-NEXT: [[PHI1:%.*]] = phi i64 [ 0, %[[LOOP_PH]] ], [ [[ADD1:%.*]], %[[LOOP]] ] -; CHECK-NEXT: [[MUL1:%.*]] = mul i64 [[PHI1]], [[SEXT7]] -; CHECK-NEXT: [[GEP11:%.*]] = getelementptr double, ptr [[GEP8]], i64 [[MUL1]] -; CHECK-NEXT: [[LOAD12:%.*]] = load double, ptr [[GEP11]], align 8 -; CHECK-NEXT: [[GEP13:%.*]] = getelementptr double, ptr [[GEP9]], i64 [[MUL1]] -; CHECK-NEXT: store double [[STORE_FORWARDED]], ptr [[GEP13]], align 8 -; CHECK-NEXT: [[ADD1]] = add i64 [[PHI1]], 1 -; CHECK-NEXT: [[ICMP:%.*]] = icmp eq i64 [[PHI1]], 1 -; CHECK-NEXT: br i1 [[ICMP]], label %[[EXIT_LOOPEXIT_LOOPEXIT1:.*]], label %[[LOOP]] -; CHECK: [[NOLOOP_EXIT]]: -; CHECK-NEXT: [[SEXT2:%.*]] = sext i32 [[LOAD]] to i64 -; CHECK-NEXT: [[GEP2:%.*]] = getelementptr double, ptr [[ARG1]], i64 [[SEXT2]] -; CHECK-NEXT: [[LOAD6:%.*]] = load double, ptr [[GEP2]], align 8 -; CHECK-NEXT: store double [[LOAD6]], ptr [[ARG]], align 8 -; CHECK-NEXT: br label %[[EXIT:.*]] -; CHECK: [[EXIT_LOOPEXIT_LOOPEXIT]]: -; CHECK-NEXT: br label %[[EXIT_LOOPEXIT:.*]] -; CHECK: [[EXIT_LOOPEXIT_LOOPEXIT1]]: -; CHECK-NEXT: br label %[[EXIT_LOOPEXIT]] -; CHECK: [[EXIT_LOOPEXIT]]: -; CHECK-NEXT: br label %[[EXIT]] -; CHECK: [[EXIT]]: -; CHECK-NEXT: ret void -; -entry: - %load = load i32, ptr %arg, align 4 - br i1 %arg2, label %noloop.exit, label %loop.ph - -loop.ph: ; preds = %entry - %sext7 = sext i32 %load to i64 - %gep8 = getelementptr i8, ptr %arg1, i64 8 - %gep9 = getelementptr i8, ptr %arg1, i64 16 - br label %loop - -loop: ; preds = %loop, %loop.ph - %phi = phi i64 [ 0, %loop.ph ], [ %add, %loop ] - %mul = mul i64 %phi, %sext7 - %gep11 = getelementptr double, ptr %gep8, i64 %mul - %load12 = load double, ptr %gep11, align 8 - %gep13 = getelementptr double, ptr %gep9, i64 %mul - store double %load12, ptr %gep13, align 8 - %add = add i64 %phi, 1 - %icmp = icmp eq i64 %phi, 1 - br i1 %icmp, label %exit, label %loop - -noloop.exit: ; preds = %loop.ph - %sext = sext i32 %load to i64 - %gep = getelementptr double, ptr %arg1, i64 %sext - %load5 = load double, ptr %gep, align 8 - store double %load5, ptr %arg, align 8 - br label %exit - -exit: ; preds = %loop.body - ret void -} diff --git a/llvm/test/Transforms/LoopLoadElim/unknown-stride-known-dep.ll b/llvm/test/Transforms/LoopLoadElim/unknown-stride-known-dep.ll new file mode 100644 index 00000000000000..e7b0968c8e8264 --- /dev/null +++ b/llvm/test/Transforms/LoopLoadElim/unknown-stride-known-dep.ll @@ -0,0 +1,91 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 +; RUN: opt -passes=loop-load-elim -S %s | FileCheck %s + +; The test was originally written as part of the investigation of #96656. +; The bug has now been marked as invalid, and we keep the test to show +; LLE's operation on known dependence returned by LAA. + +define void @unknown_stride_known_dependence(ptr %x, ptr %y, i1 %cond) { +; CHECK-LABEL: define void @unknown_stride_known_dependence( +; CHECK-SAME: ptr [[X:%.*]], ptr [[Y:%.*]], i1 [[COND:%.*]]) { +; CHECK-NEXT: [[ENTRY:.*:]] +; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr [[X]], align 4 +; CHECK-NEXT: br i1 [[COND]], label %[[NOLOOP_EXIT:.*]], label %[[LOOP_LVER_CHECK:.*]] +; CHECK: [[LOOP_LVER_CHECK]]: +; CHECK-NEXT: [[SEXT_X:%.*]] = sext i32 [[LOAD]] to i64 +; CHECK-NEXT: [[GEP_8:%.*]] = getelementptr i8, ptr [[Y]], i64 8 +; CHECK-NEXT: [[GEP_16:%.*]] = getelementptr i8, ptr [[Y]], i64 16 +; CHECK-NEXT: [[IDENT_CHECK:%.*]] = icmp ne i32 [[LOAD]], 1 +; CHECK-NEXT: br i1 [[IDENT_CHECK]], label %[[LOOP_PH_LVER_ORIG:.*]], label %[[LOOP_PH:.*]] +; CHECK: [[LOOP_PH_LVER_ORIG]]: +; CHECK-NEXT: br label %[[LOOP_LVER_ORIG:.*]] +; CHECK: [[LOOP_LVER_ORIG]]: +; CHECK-NEXT: [[IV_LVER_ORIG:%.*]] = phi i64 [ 0, %[[LOOP_PH_LVER_ORIG]] ], [ [[IV_NEXT_LVER_ORIG:%.*]], %[[LOOP_LVER_ORIG]] ] +; CHECK-NEXT: [[MUL_LVER_ORIG:%.*]] = mul i64 [[IV_LVER_ORIG]], [[SEXT_X]] +; CHECK-NEXT: [[GEP_8_MUL_LVER_ORIG:%.*]] = getelementptr double, ptr [[GEP_8]], i64 [[MUL_LVER_ORIG]] +; CHECK-NEXT: [[LOAD_8_LVER_ORIG:%.*]] = load double, ptr [[GEP_8_MUL_LVER_ORIG]], align 8 +; CHECK-NEXT: [[GEP_16_MUL_LVER_ORIG:%.*]] = getelementptr double, ptr [[GEP_16]], i64 [[MUL_LVER_ORIG]] +; CHECK-NEXT: store double [[LOAD_8_LVER_ORIG]], ptr [[GEP_16_MUL_LVER_ORIG]], align 8 +; CHECK-NEXT: [[IV_NEXT_LVER_ORIG]] = add i64 [[IV_LVER_ORIG]], 1 +; CHECK-NEXT: [[ICMP_LVER_ORIG:%.*]] = icmp eq i64 [[IV_LVER_ORIG]], 1 +; CHECK-NEXT: br i1 [[ICMP_LVER_ORIG]], label %[[EXIT_LOOPEXIT_LOOPEXIT:.*]], label %[[LOOP_LVER_ORIG]] +; CHECK: [[LOOP_PH]]: +; CHECK-NEXT: [[LOAD_INITIAL:%.*]] = load double, ptr [[GEP_8]], align 8 +; CHECK-NEXT: br label %[[LOOP:.*]] +; CHECK: [[LOOP]]: +; CHECK-NEXT: [[STORE_FORWARDED:%.*]] = phi double [ [[LOAD_INITIAL]], %[[LOOP_PH]] ], [ [[STORE_FORWARDED]], %[[LOOP]] ] +; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, %[[LOOP_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ] +; CHECK-NEXT: [[MUL:%.*]] = mul i64 [[IV]], [[SEXT_X]] +; CHECK-NEXT: [[GEP_8_MUL:%.*]] = getelementptr double, ptr [[GEP_8]], i64 [[MUL]] +; CHECK-NEXT: [[LOAD_8:%.*]] = load double, ptr [[GEP_8_MUL]], align 8 +; CHECK-NEXT: [[GEP_16_MUL:%.*]] = getelementptr double, ptr [[GEP_16]], i64 [[MUL]] +; CHECK-NEXT: store double [[STORE_FORWARDED]], ptr [[GEP_16_MUL]], align 8 +; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1 +; CHECK-NEXT: [[ICMP:%.*]] = icmp eq i64 [[IV]], 1 +; CHECK-NEXT: br i1 [[ICMP]], label %[[EXIT_LOOPEXIT_LOOPEXIT1:.*]], label %[[LOOP]] +; CHECK: [[NOLOOP_EXIT]]: +; CHECK-NEXT: [[SEXT:%.*]] = sext i32 [[LOAD]] to i64 +; CHECK-NEXT: [[GEP_Y:%.*]] = getelementptr double, ptr [[Y]], i64 [[SEXT]] +; CHECK-NEXT: [[LOAD_Y:%.*]] = load double, ptr [[GEP_Y]], align 8 +; CHECK-NEXT: store double [[LOAD_Y]], ptr [[X]], align 8 +; CHECK-NEXT: br label %[[EXIT:.*]] +; CHECK: [[EXIT_LOOPEXIT_LOOPEXIT]]: +; CHECK-NEXT: br label %[[EXIT_LOOPEXIT:.*]] +; CHECK: [[EXIT_LOOPEXIT_LOOPEXIT1]]: +; CHECK-NEXT: br label %[[EXIT_LOOPEXIT]] +; CHECK: [[EXIT_LOOPEXIT]]: +; CHECK-NEXT: br label %[[EXIT]] +; CHECK: [[EXIT]]: +; CHECK-NEXT: ret void +; +entry: + %load = load i32, ptr %x, align 4 + br i1 %cond, label %noloop.exit, label %loop.ph + +loop.ph: ; preds = %entry + %sext.x = sext i32 %load to i64 + %gep.8 = getelementptr i8, ptr %y, i64 8 + %gep.16 = getelementptr i8, ptr %y, i64 16 + br label %loop + +loop: ; preds = %loop, %loop.ph + %iv = phi i64 [ 0, %loop.ph ], [ %iv.next, %loop ] + %mul = mul i64 %iv, %sext.x + %gep.8.mul = getelementptr double, ptr %gep.8, i64 %mul + %load.8 = load double, ptr %gep.8.mul, align 8 + %gep.16.mul = getelementptr double, ptr %gep.16, i64 %mul + store double %load.8, ptr %gep.16.mul + %iv.next = add i64 %iv, 1 + %icmp = icmp eq i64 %iv, 1 + br i1 %icmp, label %exit, label %loop + +noloop.exit: ; preds = %loop.ph + %sext = sext i32 %load to i64 + %gep.y = getelementptr double, ptr %y, i64 %sext + %load.y = load double, ptr %gep.y + store double %load.y, ptr %x + br label %exit + +exit: ; preds = %loop.body + ret void +} diff --git a/llvm/test/Transforms/LoopVersioning/single-iteration.ll b/llvm/test/Transforms/LoopVersioning/single-iteration.ll index 7be34f06785853..9554f152a12e9e 100644 --- a/llvm/test/Transforms/LoopVersioning/single-iteration.ll +++ b/llvm/test/Transforms/LoopVersioning/single-iteration.ll @@ -1,17 +1,19 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 ; RUN: opt -passes=loop-versioning -S %s | FileCheck %s -; Callers should not call LoopVersioning on single-iteration loops, but LoopVersioning faithfully versions the loop when the stride is unknown and there is just a single iteration. +; Callers should not call LoopVersioning on single-iteration loops, but +; LoopVersioning faithfully versions single-iteration loops when the stride +; is unknown. -define double @single_iteration_unknown_stride(i32 %arg, ptr %arg1, i1 %arg2) { +define double @single_iteration_unknown_stride(i32 %x, ptr %y, i1 %cond) { ; CHECK-LABEL: define double @single_iteration_unknown_stride( -; CHECK-SAME: i32 [[ARG:%.*]], ptr [[ARG1:%.*]], i1 [[ARG2:%.*]]) { +; CHECK-SAME: i32 [[X:%.*]], ptr [[Y:%.*]], i1 [[COND:%.*]]) { ; CHECK-NEXT: [[ENTRY:.*:]] -; CHECK-NEXT: br i1 [[ARG2]], label %[[NOLOOP_EXIT:.*]], label %[[LOOP_BODY_LVER_CHECK:.*]] +; CHECK-NEXT: br i1 [[COND]], label %[[NOLOOP_EXIT:.*]], label %[[LOOP_BODY_LVER_CHECK:.*]] ; CHECK: [[LOOP_BODY_LVER_CHECK]]: -; CHECK-NEXT: [[SEXT7:%.*]] = sext i32 [[ARG]] to i64 -; CHECK-NEXT: [[GEP8:%.*]] = getelementptr i8, ptr [[ARG1]], i64 8 -; CHECK-NEXT: [[IDENT_CHECK:%.*]] = icmp ne i32 [[ARG]], 1 +; CHECK-NEXT: [[SEXT7:%.*]] = sext i32 [[X]] to i64 +; CHECK-NEXT: [[GEP8:%.*]] = getelementptr i8, ptr [[Y]], i64 8 +; CHECK-NEXT: [[IDENT_CHECK:%.*]] = icmp ne i32 [[X]], 1 ; CHECK-NEXT: br i1 [[IDENT_CHECK]], label %[[LOOP_BODY_PH_LVER_ORIG:.*]], label %[[LOOP_BODY_PH:.*]] ; CHECK: [[LOOP_BODY_PH_LVER_ORIG]]: ; CHECK-NEXT: br label %[[LOOP_BODY_LVER_ORIG:.*]] @@ -20,7 +22,7 @@ define double @single_iteration_unknown_stride(i32 %arg, ptr %arg1, i1 %arg2) { ; CHECK-NEXT: [[MUL_LVER_ORIG:%.*]] = mul i64 [[PHI_LVER_ORIG]], [[SEXT7]] ; CHECK-NEXT: [[GEP10_LVER_ORIG:%.*]] = getelementptr double, ptr [[GEP8]], i64 [[MUL_LVER_ORIG]] ; CHECK-NEXT: [[LOAD11_LVER_ORIG:%.*]] = load double, ptr [[GEP10_LVER_ORIG]], align 8 -; CHECK-NEXT: store double [[LOAD11_LVER_ORIG]], ptr [[ARG1]], align 8 +; CHECK-NEXT: store double [[LOAD11_LVER_ORIG]], ptr [[Y]], align 8 ; CHECK-NEXT: [[ADD_LVER_ORIG]] = add i64 [[PHI_LVER_ORIG]], 1 ; CHECK-NEXT: [[ICMP_LVER_ORIG:%.*]] = icmp eq i64 [[PHI_LVER_ORIG]], 0 ; CHECK-NEXT: br i1 [[ICMP_LVER_ORIG]], label %[[LOOP_EXIT_LOOPEXIT:.*]], label %[[LOOP_BODY_LVER_ORIG]] @@ -31,13 +33,13 @@ define double @single_iteration_unknown_stride(i32 %arg, ptr %arg1, i1 %arg2) { ; CHECK-NEXT: [[MUL:%.*]] = mul i64 [[PHI]], [[SEXT7]] ; CHECK-NEXT: [[GEP10:%.*]] = getelementptr double, ptr [[GEP8]], i64 [[MUL]] ; CHECK-NEXT: [[LOAD11:%.*]] = load double, ptr [[GEP10]], align 8 -; CHECK-NEXT: store double [[LOAD11]], ptr [[ARG1]], align 8 +; CHECK-NEXT: store double [[LOAD11]], ptr [[Y]], align 8 ; CHECK-NEXT: [[ADD]] = add i64 [[PHI]], 1 ; CHECK-NEXT: [[ICMP:%.*]] = icmp eq i64 [[PHI]], 0 ; CHECK-NEXT: br i1 [[ICMP]], label %[[LOOP_EXIT_LOOPEXIT1:.*]], label %[[LOOP_BODY]] ; CHECK: [[NOLOOP_EXIT]]: -; CHECK-NEXT: [[SEXT:%.*]] = sext i32 [[ARG]] to i64 -; CHECK-NEXT: [[GEP:%.*]] = getelementptr double, ptr [[ARG1]], i64 [[SEXT]] +; CHECK-NEXT: [[SEXT:%.*]] = sext i32 [[X]] to i64 +; CHECK-NEXT: [[GEP:%.*]] = getelementptr double, ptr [[Y]], i64 [[SEXT]] ; CHECK-NEXT: [[LOAD5:%.*]] = load double, ptr [[GEP]], align 8 ; CHECK-NEXT: ret double [[LOAD5]] ; CHECK: [[LOOP_EXIT_LOOPEXIT]]: @@ -45,38 +47,38 @@ define double @single_iteration_unknown_stride(i32 %arg, ptr %arg1, i1 %arg2) { ; CHECK: [[LOOP_EXIT_LOOPEXIT1]]: ; CHECK-NEXT: br label %[[LOOP_EXIT]] ; CHECK: [[LOOP_EXIT]]: -; CHECK-NEXT: [[SEXT2:%.*]] = sext i32 [[ARG]] to i64 -; CHECK-NEXT: [[GEP2:%.*]] = getelementptr double, ptr [[ARG1]], i64 [[SEXT2]] +; CHECK-NEXT: [[SEXT2:%.*]] = sext i32 [[X]] to i64 +; CHECK-NEXT: [[GEP2:%.*]] = getelementptr double, ptr [[Y]], i64 [[SEXT2]] ; CHECK-NEXT: [[LOAD6:%.*]] = load double, ptr [[GEP2]], align 8 ; CHECK-NEXT: ret double [[LOAD6]] ; entry: - br i1 %arg2, label %noloop.exit, label %loop.ph + br i1 %cond, label %noloop.exit, label %loop.ph loop.ph: ; preds = %entry - %sext7 = sext i32 %arg to i64 - %gep8 = getelementptr i8, ptr %arg1, i64 8 + %sext7 = sext i32 %x to i64 + %gep8 = getelementptr i8, ptr %y, i64 8 br label %loop.body loop.body: ; preds = %loop.body, %loop.ph - %phi = phi i64 [ 0, %loop.ph ], [ %add, %loop.body ] - %mul = mul i64 %phi, %sext7 + %iv = phi i64 [ 0, %loop.ph ], [ %iv.next, %loop.body ] + %mul = mul i64 %iv, %sext7 %gep10 = getelementptr double, ptr %gep8, i64 %mul %load11 = load double, ptr %gep10, align 8 - store double %load11, ptr %arg1, align 8 - %add = add i64 %phi, 1 - %icmp = icmp eq i64 %phi, 0 + store double %load11, ptr %y, align 8 + %iv.next = add i64 %iv, 1 + %icmp = icmp eq i64 %iv, 0 br i1 %icmp, label %loop.exit, label %loop.body noloop.exit: ; preds = %entry - %sext = sext i32 %arg to i64 - %gep = getelementptr double, ptr %arg1, i64 %sext + %sext = sext i32 %x to i64 + %gep = getelementptr double, ptr %y, i64 %sext %load5 = load double, ptr %gep, align 8 ret double %load5 loop.exit: ; preds = %loop.body - %sext2 = sext i32 %arg to i64 - %gep2 = getelementptr double, ptr %arg1, i64 %sext2 + %sext2 = sext i32 %x to i64 + %gep2 = getelementptr double, ptr %y, i64 %sext2 %load6 = load double, ptr %gep2, align 8 ret double %load6 }