| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals none --version 4 |
| ; RUN: opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=4 -S %s | FileCheck --check-prefix=VF4IC4 %s |
| |
| declare void @init_mem(ptr, i64); |
| |
| define i64 @multi_exiting_to_different_exits_live_in_exit_values() { |
| ; VF4IC4-LABEL: define i64 @multi_exiting_to_different_exits_live_in_exit_values() { |
| ; VF4IC4-NEXT: entry: |
| ; VF4IC4-NEXT: [[SRC:%.*]] = alloca [128 x i32], align 4 |
| ; VF4IC4-NEXT: call void @init_mem(ptr [[SRC]]) |
| ; VF4IC4-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] |
| ; VF4IC4: vector.ph: |
| ; VF4IC4-NEXT: br label [[VECTOR_BODY:%.*]] |
| ; VF4IC4: vector.body: |
| ; VF4IC4-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] |
| ; VF4IC4-NEXT: [[TMP0:%.*]] = getelementptr inbounds i32, ptr [[SRC]], i64 [[INDEX]] |
| ; VF4IC4-NEXT: [[TMP1:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i32 0 |
| ; VF4IC4-NEXT: [[WIDE_LOAD3:%.*]] = load <4 x i32>, ptr [[TMP1]], align 4 |
| ; VF4IC4-NEXT: [[TMP8:%.*]] = icmp eq <4 x i32> [[WIDE_LOAD3]], splat (i32 10) |
| ; VF4IC4-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4 |
| ; VF4IC4-NEXT: [[TMP3:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP8]]) |
| ; VF4IC4-NEXT: [[TMP4:%.*]] = icmp eq i64 [[INDEX_NEXT]], 128 |
| ; VF4IC4-NEXT: [[TMP5:%.*]] = or i1 [[TMP3]], [[TMP4]] |
| ; VF4IC4-NEXT: br i1 [[TMP5]], label [[MIDDLE_SPLIT:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]] |
| ; VF4IC4: middle.split: |
| ; VF4IC4-NEXT: br i1 [[TMP3]], label [[VECTOR_EARLY_EXIT:%.*]], label [[MIDDLE_BLOCK:%.*]] |
| ; VF4IC4: middle.block: |
| ; VF4IC4-NEXT: br i1 true, label [[E2:%.*]], label [[SCALAR_PH]] |
| ; VF4IC4: vector.early.exit: |
| ; VF4IC4-NEXT: br label [[E1:%.*]] |
| ; VF4IC4: scalar.ph: |
| ; VF4IC4-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 128, [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ] |
| ; VF4IC4-NEXT: br label [[LOOP_HEADER:%.*]] |
| ; VF4IC4: loop.header: |
| ; VF4IC4-NEXT: [[IV:%.*]] = phi i64 [ [[INC:%.*]], [[LOOP_LATCH:%.*]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ] |
| ; VF4IC4-NEXT: [[GEP_SRC:%.*]] = getelementptr inbounds i32, ptr [[SRC]], i64 [[IV]] |
| ; VF4IC4-NEXT: [[L:%.*]] = load i32, ptr [[GEP_SRC]], align 4 |
| ; VF4IC4-NEXT: [[C_1:%.*]] = icmp eq i32 [[L]], 10 |
| ; VF4IC4-NEXT: br i1 [[C_1]], label [[E1]], label [[LOOP_LATCH]] |
| ; VF4IC4: loop.latch: |
| ; VF4IC4-NEXT: [[INC]] = add nuw i64 [[IV]], 1 |
| ; VF4IC4-NEXT: [[C_2:%.*]] = icmp eq i64 [[INC]], 128 |
| ; VF4IC4-NEXT: br i1 [[C_2]], label [[E2]], label [[LOOP_HEADER]], !llvm.loop [[LOOP3:![0-9]+]] |
| ; VF4IC4: e1: |
| ; VF4IC4-NEXT: [[P1:%.*]] = phi i64 [ 0, [[LOOP_HEADER]] ], [ 0, [[VECTOR_EARLY_EXIT]] ] |
| ; VF4IC4-NEXT: ret i64 [[P1]] |
| ; VF4IC4: e2: |
| ; VF4IC4-NEXT: [[P2:%.*]] = phi i64 [ 1, [[LOOP_LATCH]] ], [ 1, [[MIDDLE_BLOCK]] ] |
| ; VF4IC4-NEXT: ret i64 [[P2]] |
| ; |
| entry: |
| %src = alloca [128 x i32] |
| call void @init_mem(ptr %src) |
| br label %loop.header |
| |
| loop.header: |
| %iv = phi i64 [ %inc, %loop.latch ], [ 0, %entry ] |
| %gep.src = getelementptr inbounds i32, ptr %src, i64 %iv |
| %l = load i32, ptr %gep.src |
| %c.1 = icmp eq i32 %l, 10 |
| br i1 %c.1, label %e1, label %loop.latch |
| |
| loop.latch: |
| %inc = add nuw i64 %iv, 1 |
| %c.2 = icmp eq i64 %inc, 128 |
| br i1 %c.2, label %e2, label %loop.header |
| |
| e1: |
| %p1 = phi i64 [ 0, %loop.header ] |
| ret i64 %p1 |
| |
| e2: |
| %p2 = phi i64 [ 1, %loop.latch ] |
| ret i64 %p2 |
| } |
| |
| define i64 @same_exit_block_pre_inc_use1() { |
| ; VF4IC4-LABEL: define i64 @same_exit_block_pre_inc_use1() { |
| ; VF4IC4-NEXT: entry: |
| ; VF4IC4-NEXT: [[P1:%.*]] = alloca [1024 x i8], align 1 |
| ; VF4IC4-NEXT: [[P2:%.*]] = alloca [1024 x i8], align 1 |
| ; VF4IC4-NEXT: call void @init_mem(ptr [[P1]], i64 1024) |
| ; VF4IC4-NEXT: call void @init_mem(ptr [[P2]], i64 1024) |
| ; VF4IC4-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] |
| ; VF4IC4: vector.ph: |
| ; VF4IC4-NEXT: br label [[VECTOR_BODY:%.*]] |
| ; VF4IC4: vector.body: |
| ; VF4IC4-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] |
| ; VF4IC4-NEXT: [[OFFSET_IDX:%.*]] = add i64 3, [[INDEX]] |
| ; VF4IC4-NEXT: [[TMP0:%.*]] = getelementptr inbounds i8, ptr [[P1]], i64 [[OFFSET_IDX]] |
| ; VF4IC4-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, ptr [[TMP0]], i32 0 |
| ; VF4IC4-NEXT: [[WIDE_LOAD3:%.*]] = load <4 x i8>, ptr [[TMP1]], align 1 |
| ; VF4IC4-NEXT: [[TMP18:%.*]] = getelementptr inbounds i8, ptr [[P2]], i64 [[OFFSET_IDX]] |
| ; VF4IC4-NEXT: [[TMP19:%.*]] = getelementptr inbounds i8, ptr [[TMP18]], i32 0 |
| ; VF4IC4-NEXT: [[WIDE_LOAD7:%.*]] = load <4 x i8>, ptr [[TMP19]], align 1 |
| ; VF4IC4-NEXT: [[TMP13:%.*]] = icmp ne <4 x i8> [[WIDE_LOAD3]], [[WIDE_LOAD7]] |
| ; VF4IC4-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4 |
| ; VF4IC4-NEXT: [[TMP5:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP13]]) |
| ; VF4IC4-NEXT: [[TMP6:%.*]] = icmp eq i64 [[INDEX_NEXT]], 64 |
| ; VF4IC4-NEXT: [[TMP7:%.*]] = or i1 [[TMP5]], [[TMP6]] |
| ; VF4IC4-NEXT: br i1 [[TMP7]], label [[MIDDLE_SPLIT:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP4:![0-9]+]] |
| ; VF4IC4: middle.split: |
| ; VF4IC4-NEXT: br i1 [[TMP5]], label [[VECTOR_EARLY_EXIT:%.*]], label [[MIDDLE_BLOCK:%.*]] |
| ; VF4IC4: middle.block: |
| ; VF4IC4-NEXT: br i1 true, label [[LOOP_END:%.*]], label [[SCALAR_PH]] |
| ; VF4IC4: vector.early.exit: |
| ; VF4IC4-NEXT: [[TMP8:%.*]] = call i64 @llvm.experimental.cttz.elts.i64.v4i1(<4 x i1> [[TMP13]], i1 true) |
| ; VF4IC4-NEXT: [[TMP9:%.*]] = add i64 [[INDEX]], [[TMP8]] |
| ; VF4IC4-NEXT: [[TMP10:%.*]] = add i64 3, [[TMP9]] |
| ; VF4IC4-NEXT: br label [[LOOP_END]] |
| ; VF4IC4: scalar.ph: |
| ; VF4IC4-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 67, [[MIDDLE_BLOCK]] ], [ 3, [[ENTRY:%.*]] ] |
| ; VF4IC4-NEXT: br label [[LOOP:%.*]] |
| ; VF4IC4: loop: |
| ; VF4IC4-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[LOOP_INC:%.*]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ] |
| ; VF4IC4-NEXT: [[GEP_P1:%.*]] = getelementptr inbounds i8, ptr [[P1]], i64 [[IV]] |
| ; VF4IC4-NEXT: [[LD1:%.*]] = load i8, ptr [[GEP_P1]], align 1 |
| ; VF4IC4-NEXT: [[GEP_P2:%.*]] = getelementptr inbounds i8, ptr [[P2]], i64 [[IV]] |
| ; VF4IC4-NEXT: [[LD2:%.*]] = load i8, ptr [[GEP_P2]], align 1 |
| ; VF4IC4-NEXT: [[CMP3:%.*]] = icmp eq i8 [[LD1]], [[LD2]] |
| ; VF4IC4-NEXT: br i1 [[CMP3]], label [[LOOP_INC]], label [[LOOP_END]] |
| ; VF4IC4: loop.inc: |
| ; VF4IC4-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1 |
| ; VF4IC4-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[IV_NEXT]], 67 |
| ; VF4IC4-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[LOOP_END]], !llvm.loop [[LOOP5:![0-9]+]] |
| ; VF4IC4: loop.end: |
| ; VF4IC4-NEXT: [[RETVAL:%.*]] = phi i64 [ [[IV]], [[LOOP]] ], [ 67, [[LOOP_INC]] ], [ 67, [[MIDDLE_BLOCK]] ], [ [[TMP10]], [[VECTOR_EARLY_EXIT]] ] |
| ; VF4IC4-NEXT: ret i64 [[RETVAL]] |
| ; |
| entry: |
| %p1 = alloca [1024 x i8] |
| %p2 = alloca [1024 x i8] |
| call void @init_mem(ptr %p1, i64 1024) |
| call void @init_mem(ptr %p2, i64 1024) |
| br label %loop |
| |
| loop: |
| %iv = phi i64 [ %iv.next, %loop.inc ], [ 3, %entry ] |
| %gep.p1 = getelementptr inbounds i8, ptr %p1, i64 %iv |
| %ld1 = load i8, ptr %gep.p1, align 1 |
| %gep.p2 = getelementptr inbounds i8, ptr %p2, i64 %iv |
| %ld2 = load i8, ptr %gep.p2, align 1 |
| %cmp3 = icmp eq i8 %ld1, %ld2 |
| br i1 %cmp3, label %loop.inc, label %loop.end |
| |
| loop.inc: |
| %iv.next = add i64 %iv, 1 |
| %exitcond = icmp ne i64 %iv.next, 67 |
| br i1 %exitcond, label %loop, label %loop.end |
| |
| loop.end: |
| %retval = phi i64 [ %iv, %loop ], [ 67, %loop.inc ] |
| ret i64 %retval |
| } |
| |
| define ptr @same_exit_block_pre_inc_use1_ivptr() { |
| ; VF4IC4-LABEL: define ptr @same_exit_block_pre_inc_use1_ivptr() { |
| ; VF4IC4-NEXT: entry: |
| ; VF4IC4-NEXT: [[P1:%.*]] = alloca [1024 x i8], align 1 |
| ; VF4IC4-NEXT: call void @init_mem(ptr [[P1]], i64 1024) |
| ; VF4IC4-NEXT: [[PTREND:%.*]] = getelementptr i8, ptr [[P1]], i64 1024 |
| ; VF4IC4-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] |
| ; VF4IC4: vector.ph: |
| ; VF4IC4-NEXT: [[TMP0:%.*]] = getelementptr i8, ptr [[P1]], i64 1024 |
| ; VF4IC4-NEXT: br label [[VECTOR_BODY:%.*]] |
| ; VF4IC4: vector.body: |
| ; VF4IC4-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] |
| ; VF4IC4-NEXT: [[NEXT_GEP:%.*]] = getelementptr i8, ptr [[P1]], i64 [[INDEX]] |
| ; VF4IC4-NEXT: [[TMP1:%.*]] = getelementptr i8, ptr [[NEXT_GEP]], i32 0 |
| ; VF4IC4-NEXT: [[WIDE_LOAD3:%.*]] = load <4 x i8>, ptr [[TMP1]], align 1 |
| ; VF4IC4-NEXT: [[TMP17:%.*]] = icmp ne <4 x i8> [[WIDE_LOAD3]], splat (i8 72) |
| ; VF4IC4-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4 |
| ; VF4IC4-NEXT: [[TMP3:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP17]]) |
| ; VF4IC4-NEXT: [[TMP4:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1024 |
| ; VF4IC4-NEXT: [[TMP5:%.*]] = or i1 [[TMP3]], [[TMP4]] |
| ; VF4IC4-NEXT: br i1 [[TMP5]], label [[MIDDLE_SPLIT:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP6:![0-9]+]] |
| ; VF4IC4: middle.split: |
| ; VF4IC4-NEXT: br i1 [[TMP3]], label [[VECTOR_EARLY_EXIT:%.*]], label [[MIDDLE_BLOCK:%.*]] |
| ; VF4IC4: middle.block: |
| ; VF4IC4-NEXT: br i1 true, label [[LOOP_END:%.*]], label [[SCALAR_PH]] |
| ; VF4IC4: vector.early.exit: |
| ; VF4IC4-NEXT: [[TMP6:%.*]] = call i64 @llvm.experimental.cttz.elts.i64.v4i1(<4 x i1> [[TMP17]], i1 true) |
| ; VF4IC4-NEXT: [[TMP7:%.*]] = add i64 [[INDEX]], [[TMP6]] |
| ; VF4IC4-NEXT: [[TMP8:%.*]] = getelementptr i8, ptr [[P1]], i64 [[TMP7]] |
| ; VF4IC4-NEXT: br label [[LOOP_END]] |
| ; VF4IC4: scalar.ph: |
| ; VF4IC4-NEXT: [[BC_RESUME_VAL:%.*]] = phi ptr [ [[TMP0]], [[MIDDLE_BLOCK]] ], [ [[P1]], [[ENTRY:%.*]] ] |
| ; VF4IC4-NEXT: br label [[LOOP:%.*]] |
| ; VF4IC4: loop: |
| ; VF4IC4-NEXT: [[PTR:%.*]] = phi ptr [ [[PTR_NEXT:%.*]], [[LOOP_INC:%.*]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ] |
| ; VF4IC4-NEXT: [[LD1:%.*]] = load i8, ptr [[PTR]], align 1 |
| ; VF4IC4-NEXT: [[CMP3:%.*]] = icmp eq i8 [[LD1]], 72 |
| ; VF4IC4-NEXT: br i1 [[CMP3]], label [[LOOP_INC]], label [[LOOP_END]] |
| ; VF4IC4: loop.inc: |
| ; VF4IC4-NEXT: [[PTR_NEXT]] = getelementptr inbounds i8, ptr [[PTR]], i64 1 |
| ; VF4IC4-NEXT: [[EXITCOND:%.*]] = icmp ne ptr [[PTR_NEXT]], [[PTREND]] |
| ; VF4IC4-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[LOOP_END]], !llvm.loop [[LOOP7:![0-9]+]] |
| ; VF4IC4: loop.end: |
| ; VF4IC4-NEXT: [[RETVAL:%.*]] = phi ptr [ [[PTR]], [[LOOP]] ], [ [[PTREND]], [[LOOP_INC]] ], [ [[PTREND]], [[MIDDLE_BLOCK]] ], [ [[TMP8]], [[VECTOR_EARLY_EXIT]] ] |
| ; VF4IC4-NEXT: ret ptr [[RETVAL]] |
| ; |
| entry: |
| %p1 = alloca [1024 x i8] |
| call void @init_mem(ptr %p1, i64 1024) |
| %ptrend = getelementptr i8, ptr %p1, i64 1024 |
| br label %loop |
| |
| loop: |
| %ptr = phi ptr [ %ptr.next, %loop.inc ], [ %p1, %entry ] |
| %ld1 = load i8, ptr %ptr, align 1 |
| %cmp3 = icmp eq i8 %ld1, 72 |
| br i1 %cmp3, label %loop.inc, label %loop.end |
| |
| loop.inc: |
| %ptr.next = getelementptr inbounds i8, ptr %ptr, i64 1 |
| %exitcond = icmp ne ptr %ptr.next, %ptrend |
| br i1 %exitcond, label %loop, label %loop.end |
| |
| loop.end: |
| %retval = phi ptr [ %ptr, %loop ], [ %ptrend, %loop.inc ] |
| ret ptr %retval |
| } |
| |
| define i64 @same_exit_block_post_inc_use() { |
| ; VF4IC4-LABEL: define i64 @same_exit_block_post_inc_use() { |
| ; VF4IC4-NEXT: entry: |
| ; VF4IC4-NEXT: [[P1:%.*]] = alloca [1024 x i8], align 1 |
| ; VF4IC4-NEXT: [[P2:%.*]] = alloca [1024 x i8], align 1 |
| ; VF4IC4-NEXT: call void @init_mem(ptr [[P1]], i64 1024) |
| ; VF4IC4-NEXT: call void @init_mem(ptr [[P2]], i64 1024) |
| ; VF4IC4-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] |
| ; VF4IC4: vector.ph: |
| ; VF4IC4-NEXT: br label [[VECTOR_BODY:%.*]] |
| ; VF4IC4: vector.body: |
| ; VF4IC4-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] |
| ; VF4IC4-NEXT: [[OFFSET_IDX:%.*]] = add i64 3, [[INDEX]] |
| ; VF4IC4-NEXT: [[TMP0:%.*]] = getelementptr inbounds i8, ptr [[P1]], i64 [[OFFSET_IDX]] |
| ; VF4IC4-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, ptr [[TMP0]], i32 0 |
| ; VF4IC4-NEXT: [[WIDE_LOAD3:%.*]] = load <4 x i8>, ptr [[TMP1]], align 1 |
| ; VF4IC4-NEXT: [[TMP18:%.*]] = getelementptr inbounds i8, ptr [[P2]], i64 [[OFFSET_IDX]] |
| ; VF4IC4-NEXT: [[TMP19:%.*]] = getelementptr inbounds i8, ptr [[TMP18]], i32 0 |
| ; VF4IC4-NEXT: [[WIDE_LOAD7:%.*]] = load <4 x i8>, ptr [[TMP19]], align 1 |
| ; VF4IC4-NEXT: [[TMP13:%.*]] = icmp ne <4 x i8> [[WIDE_LOAD3]], [[WIDE_LOAD7]] |
| ; VF4IC4-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4 |
| ; VF4IC4-NEXT: [[TMP5:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP13]]) |
| ; VF4IC4-NEXT: [[TMP6:%.*]] = icmp eq i64 [[INDEX_NEXT]], 64 |
| ; VF4IC4-NEXT: [[TMP7:%.*]] = or i1 [[TMP5]], [[TMP6]] |
| ; VF4IC4-NEXT: br i1 [[TMP7]], label [[MIDDLE_SPLIT:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP8:![0-9]+]] |
| ; VF4IC4: middle.split: |
| ; VF4IC4-NEXT: br i1 [[TMP5]], label [[VECTOR_EARLY_EXIT:%.*]], label [[MIDDLE_BLOCK:%.*]] |
| ; VF4IC4: middle.block: |
| ; VF4IC4-NEXT: br i1 true, label [[LOOP_END:%.*]], label [[SCALAR_PH]] |
| ; VF4IC4: vector.early.exit: |
| ; VF4IC4-NEXT: [[TMP8:%.*]] = call i64 @llvm.experimental.cttz.elts.i64.v4i1(<4 x i1> [[TMP13]], i1 true) |
| ; VF4IC4-NEXT: [[TMP9:%.*]] = add i64 [[INDEX]], [[TMP8]] |
| ; VF4IC4-NEXT: [[TMP10:%.*]] = add i64 3, [[TMP9]] |
| ; VF4IC4-NEXT: br label [[LOOP_END]] |
| ; VF4IC4: scalar.ph: |
| ; VF4IC4-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 67, [[MIDDLE_BLOCK]] ], [ 3, [[ENTRY:%.*]] ] |
| ; VF4IC4-NEXT: br label [[LOOP:%.*]] |
| ; VF4IC4: loop: |
| ; VF4IC4-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[LOOP_INC:%.*]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ] |
| ; VF4IC4-NEXT: [[GEP_P1:%.*]] = getelementptr inbounds i8, ptr [[P1]], i64 [[IV]] |
| ; VF4IC4-NEXT: [[LD1:%.*]] = load i8, ptr [[GEP_P1]], align 1 |
| ; VF4IC4-NEXT: [[GEP_P2:%.*]] = getelementptr inbounds i8, ptr [[P2]], i64 [[IV]] |
| ; VF4IC4-NEXT: [[LD2:%.*]] = load i8, ptr [[GEP_P2]], align 1 |
| ; VF4IC4-NEXT: [[CMP3:%.*]] = icmp eq i8 [[LD1]], [[LD2]] |
| ; VF4IC4-NEXT: br i1 [[CMP3]], label [[LOOP_INC]], label [[LOOP_END]] |
| ; VF4IC4: loop.inc: |
| ; VF4IC4-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1 |
| ; VF4IC4-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[IV_NEXT]], 67 |
| ; VF4IC4-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[LOOP_END]], !llvm.loop [[LOOP9:![0-9]+]] |
| ; VF4IC4: loop.end: |
| ; VF4IC4-NEXT: [[RETVAL:%.*]] = phi i64 [ [[IV]], [[LOOP]] ], [ [[IV_NEXT]], [[LOOP_INC]] ], [ 67, [[MIDDLE_BLOCK]] ], [ [[TMP10]], [[VECTOR_EARLY_EXIT]] ] |
| ; VF4IC4-NEXT: ret i64 [[RETVAL]] |
| ; |
| entry: |
| %p1 = alloca [1024 x i8] |
| %p2 = alloca [1024 x i8] |
| call void @init_mem(ptr %p1, i64 1024) |
| call void @init_mem(ptr %p2, i64 1024) |
| br label %loop |
| |
| loop: |
| %iv = phi i64 [ %iv.next, %loop.inc ], [ 3, %entry ] |
| %gep.p1 = getelementptr inbounds i8, ptr %p1, i64 %iv |
| %ld1 = load i8, ptr %gep.p1, align 1 |
| %gep.p2 = getelementptr inbounds i8, ptr %p2, i64 %iv |
| %ld2 = load i8, ptr %gep.p2, align 1 |
| %cmp3 = icmp eq i8 %ld1, %ld2 |
| br i1 %cmp3, label %loop.inc, label %loop.end |
| |
| loop.inc: |
| %iv.next = add i64 %iv, 1 |
| %exitcond = icmp ne i64 %iv.next, 67 |
| br i1 %exitcond, label %loop, label %loop.end |
| |
| loop.end: |
| %retval = phi i64 [ %iv, %loop ], [ %iv.next, %loop.inc ] |
| ret i64 %retval |
| } |
| |
| define i64 @diff_exit_block_pre_inc_use1() { |
| ; VF4IC4-LABEL: define i64 @diff_exit_block_pre_inc_use1() { |
| ; VF4IC4-NEXT: entry: |
| ; VF4IC4-NEXT: [[P1:%.*]] = alloca [1024 x i8], align 1 |
| ; VF4IC4-NEXT: [[P2:%.*]] = alloca [1024 x i8], align 1 |
| ; VF4IC4-NEXT: call void @init_mem(ptr [[P1]], i64 1024) |
| ; VF4IC4-NEXT: call void @init_mem(ptr [[P2]], i64 1024) |
| ; VF4IC4-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] |
| ; VF4IC4: vector.ph: |
| ; VF4IC4-NEXT: br label [[VECTOR_BODY:%.*]] |
| ; VF4IC4: vector.body: |
| ; VF4IC4-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] |
| ; VF4IC4-NEXT: [[OFFSET_IDX:%.*]] = add i64 3, [[INDEX]] |
| ; VF4IC4-NEXT: [[TMP0:%.*]] = getelementptr inbounds i8, ptr [[P1]], i64 [[OFFSET_IDX]] |
| ; VF4IC4-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, ptr [[TMP0]], i32 0 |
| ; VF4IC4-NEXT: [[WIDE_LOAD3:%.*]] = load <4 x i8>, ptr [[TMP1]], align 1 |
| ; VF4IC4-NEXT: [[TMP18:%.*]] = getelementptr inbounds i8, ptr [[P2]], i64 [[OFFSET_IDX]] |
| ; VF4IC4-NEXT: [[TMP19:%.*]] = getelementptr inbounds i8, ptr [[TMP18]], i32 0 |
| ; VF4IC4-NEXT: [[WIDE_LOAD7:%.*]] = load <4 x i8>, ptr [[TMP19]], align 1 |
| ; VF4IC4-NEXT: [[TMP13:%.*]] = icmp ne <4 x i8> [[WIDE_LOAD3]], [[WIDE_LOAD7]] |
| ; VF4IC4-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4 |
| ; VF4IC4-NEXT: [[TMP5:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP13]]) |
| ; VF4IC4-NEXT: [[TMP6:%.*]] = icmp eq i64 [[INDEX_NEXT]], 64 |
| ; VF4IC4-NEXT: [[TMP7:%.*]] = or i1 [[TMP5]], [[TMP6]] |
| ; VF4IC4-NEXT: br i1 [[TMP7]], label [[MIDDLE_SPLIT:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP10:![0-9]+]] |
| ; VF4IC4: middle.split: |
| ; VF4IC4-NEXT: br i1 [[TMP5]], label [[VECTOR_EARLY_EXIT:%.*]], label [[MIDDLE_BLOCK:%.*]] |
| ; VF4IC4: middle.block: |
| ; VF4IC4-NEXT: br i1 true, label [[LOOP_END:%.*]], label [[SCALAR_PH]] |
| ; VF4IC4: vector.early.exit: |
| ; VF4IC4-NEXT: [[TMP8:%.*]] = call i64 @llvm.experimental.cttz.elts.i64.v4i1(<4 x i1> [[TMP13]], i1 true) |
| ; VF4IC4-NEXT: [[TMP9:%.*]] = add i64 [[INDEX]], [[TMP8]] |
| ; VF4IC4-NEXT: [[TMP10:%.*]] = add i64 3, [[TMP9]] |
| ; VF4IC4-NEXT: br label [[LOOP_EARLY_EXIT:%.*]] |
| ; VF4IC4: scalar.ph: |
| ; VF4IC4-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 67, [[MIDDLE_BLOCK]] ], [ 3, [[ENTRY:%.*]] ] |
| ; VF4IC4-NEXT: br label [[LOOP:%.*]] |
| ; VF4IC4: loop: |
| ; VF4IC4-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[LOOP_INC:%.*]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ] |
| ; VF4IC4-NEXT: [[GEP_P1:%.*]] = getelementptr inbounds i8, ptr [[P1]], i64 [[IV]] |
| ; VF4IC4-NEXT: [[LD1:%.*]] = load i8, ptr [[GEP_P1]], align 1 |
| ; VF4IC4-NEXT: [[GEP_P2:%.*]] = getelementptr inbounds i8, ptr [[P2]], i64 [[IV]] |
| ; VF4IC4-NEXT: [[LD2:%.*]] = load i8, ptr [[GEP_P2]], align 1 |
| ; VF4IC4-NEXT: [[CMP3:%.*]] = icmp eq i8 [[LD1]], [[LD2]] |
| ; VF4IC4-NEXT: br i1 [[CMP3]], label [[LOOP_INC]], label [[LOOP_EARLY_EXIT]] |
| ; VF4IC4: loop.inc: |
| ; VF4IC4-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1 |
| ; VF4IC4-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[IV_NEXT]], 67 |
| ; VF4IC4-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[LOOP_END]], !llvm.loop [[LOOP11:![0-9]+]] |
| ; VF4IC4: loop.early.exit: |
| ; VF4IC4-NEXT: [[RETVAL1:%.*]] = phi i64 [ [[IV]], [[LOOP]] ], [ [[TMP10]], [[VECTOR_EARLY_EXIT]] ] |
| ; VF4IC4-NEXT: ret i64 [[RETVAL1]] |
| ; VF4IC4: loop.end: |
| ; VF4IC4-NEXT: [[RETVAL2:%.*]] = phi i64 [ 67, [[LOOP_INC]] ], [ 67, [[MIDDLE_BLOCK]] ] |
| ; VF4IC4-NEXT: ret i64 [[RETVAL2]] |
| ; |
| entry: |
| %p1 = alloca [1024 x i8] |
| %p2 = alloca [1024 x i8] |
| call void @init_mem(ptr %p1, i64 1024) |
| call void @init_mem(ptr %p2, i64 1024) |
| br label %loop |
| |
| loop: |
| %iv = phi i64 [ %iv.next, %loop.inc ], [ 3, %entry ] |
| %gep.p1 = getelementptr inbounds i8, ptr %p1, i64 %iv |
| %ld1 = load i8, ptr %gep.p1, align 1 |
| %gep.p2 = getelementptr inbounds i8, ptr %p2, i64 %iv |
| %ld2 = load i8, ptr %gep.p2, align 1 |
| %cmp3 = icmp eq i8 %ld1, %ld2 |
| br i1 %cmp3, label %loop.inc, label %loop.early.exit |
| |
| loop.inc: |
| %iv.next = add i64 %iv, 1 |
| %exitcond = icmp ne i64 %iv.next, 67 |
| br i1 %exitcond, label %loop, label %loop.end |
| |
| loop.early.exit: |
| %retval1 = phi i64 [ %iv, %loop ] |
| ret i64 %retval1 |
| |
| loop.end: |
| %retval2 = phi i64 [ 67, %loop.inc ] |
| ret i64 %retval2 |
| } |
| |
| define i64 @diff_exit_block_post_inc_use1() { |
| ; VF4IC4-LABEL: define i64 @diff_exit_block_post_inc_use1() { |
| ; VF4IC4-NEXT: entry: |
| ; VF4IC4-NEXT: [[P1:%.*]] = alloca [1024 x i8], align 1 |
| ; VF4IC4-NEXT: [[P2:%.*]] = alloca [1024 x i8], align 1 |
| ; VF4IC4-NEXT: call void @init_mem(ptr [[P1]], i64 1024) |
| ; VF4IC4-NEXT: call void @init_mem(ptr [[P2]], i64 1024) |
| ; VF4IC4-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] |
| ; VF4IC4: vector.ph: |
| ; VF4IC4-NEXT: br label [[VECTOR_BODY:%.*]] |
| ; VF4IC4: vector.body: |
| ; VF4IC4-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] |
| ; VF4IC4-NEXT: [[OFFSET_IDX:%.*]] = add i64 3, [[INDEX]] |
| ; VF4IC4-NEXT: [[TMP0:%.*]] = getelementptr inbounds i8, ptr [[P1]], i64 [[OFFSET_IDX]] |
| ; VF4IC4-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, ptr [[TMP0]], i32 0 |
| ; VF4IC4-NEXT: [[WIDE_LOAD3:%.*]] = load <4 x i8>, ptr [[TMP1]], align 1 |
| ; VF4IC4-NEXT: [[TMP18:%.*]] = getelementptr inbounds i8, ptr [[P2]], i64 [[OFFSET_IDX]] |
| ; VF4IC4-NEXT: [[TMP19:%.*]] = getelementptr inbounds i8, ptr [[TMP18]], i32 0 |
| ; VF4IC4-NEXT: [[WIDE_LOAD7:%.*]] = load <4 x i8>, ptr [[TMP19]], align 1 |
| ; VF4IC4-NEXT: [[TMP13:%.*]] = icmp ne <4 x i8> [[WIDE_LOAD3]], [[WIDE_LOAD7]] |
| ; VF4IC4-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4 |
| ; VF4IC4-NEXT: [[TMP5:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP13]]) |
| ; VF4IC4-NEXT: [[TMP6:%.*]] = icmp eq i64 [[INDEX_NEXT]], 64 |
| ; VF4IC4-NEXT: [[TMP7:%.*]] = or i1 [[TMP5]], [[TMP6]] |
| ; VF4IC4-NEXT: br i1 [[TMP7]], label [[MIDDLE_SPLIT:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP12:![0-9]+]] |
| ; VF4IC4: middle.split: |
| ; VF4IC4-NEXT: br i1 [[TMP5]], label [[VECTOR_EARLY_EXIT:%.*]], label [[MIDDLE_BLOCK:%.*]] |
| ; VF4IC4: middle.block: |
| ; VF4IC4-NEXT: br i1 true, label [[LOOP_END:%.*]], label [[SCALAR_PH]] |
| ; VF4IC4: vector.early.exit: |
| ; VF4IC4-NEXT: [[TMP8:%.*]] = call i64 @llvm.experimental.cttz.elts.i64.v4i1(<4 x i1> [[TMP13]], i1 true) |
| ; VF4IC4-NEXT: [[TMP9:%.*]] = add i64 [[INDEX]], [[TMP8]] |
| ; VF4IC4-NEXT: [[TMP10:%.*]] = add i64 3, [[TMP9]] |
| ; VF4IC4-NEXT: br label [[LOOP_EARLY_EXIT:%.*]] |
| ; VF4IC4: scalar.ph: |
| ; VF4IC4-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 67, [[MIDDLE_BLOCK]] ], [ 3, [[ENTRY:%.*]] ] |
| ; VF4IC4-NEXT: br label [[LOOP:%.*]] |
| ; VF4IC4: loop: |
| ; VF4IC4-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[LOOP_INC:%.*]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ] |
| ; VF4IC4-NEXT: [[GEP_P1:%.*]] = getelementptr inbounds i8, ptr [[P1]], i64 [[IV]] |
| ; VF4IC4-NEXT: [[LD1:%.*]] = load i8, ptr [[GEP_P1]], align 1 |
| ; VF4IC4-NEXT: [[GEP_P2:%.*]] = getelementptr inbounds i8, ptr [[P2]], i64 [[IV]] |
| ; VF4IC4-NEXT: [[LD2:%.*]] = load i8, ptr [[GEP_P2]], align 1 |
| ; VF4IC4-NEXT: [[CMP3:%.*]] = icmp eq i8 [[LD1]], [[LD2]] |
| ; VF4IC4-NEXT: br i1 [[CMP3]], label [[LOOP_INC]], label [[LOOP_EARLY_EXIT]] |
| ; VF4IC4: loop.inc: |
| ; VF4IC4-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1 |
| ; VF4IC4-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[IV_NEXT]], 67 |
| ; VF4IC4-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[LOOP_END]], !llvm.loop [[LOOP13:![0-9]+]] |
| ; VF4IC4: loop.early.exit: |
| ; VF4IC4-NEXT: [[RETVAL1:%.*]] = phi i64 [ [[IV]], [[LOOP]] ], [ [[TMP10]], [[VECTOR_EARLY_EXIT]] ] |
| ; VF4IC4-NEXT: ret i64 [[RETVAL1]] |
| ; VF4IC4: loop.end: |
| ; VF4IC4-NEXT: [[RETVAL2:%.*]] = phi i64 [ [[IV_NEXT]], [[LOOP_INC]] ], [ 67, [[MIDDLE_BLOCK]] ] |
| ; VF4IC4-NEXT: ret i64 [[RETVAL2]] |
| ; |
| entry: |
| %p1 = alloca [1024 x i8] |
| %p2 = alloca [1024 x i8] |
| call void @init_mem(ptr %p1, i64 1024) |
| call void @init_mem(ptr %p2, i64 1024) |
| br label %loop |
| |
| loop: |
| %iv = phi i64 [ %iv.next, %loop.inc ], [ 3, %entry ] |
| %gep.p1 = getelementptr inbounds i8, ptr %p1, i64 %iv |
| %ld1 = load i8, ptr %gep.p1, align 1 |
| %gep.p2 = getelementptr inbounds i8, ptr %p2, i64 %iv |
| %ld2 = load i8, ptr %gep.p2, align 1 |
| %cmp3 = icmp eq i8 %ld1, %ld2 |
| br i1 %cmp3, label %loop.inc, label %loop.early.exit |
| |
| loop.inc: |
| %iv.next = add i64 %iv, 1 |
| %exitcond = icmp ne i64 %iv.next, 67 |
| br i1 %exitcond, label %loop, label %loop.end |
| |
| loop.early.exit: |
| %retval1 = phi i64 [ %iv, %loop ] |
| ret i64 %retval1 |
| |
| loop.end: |
| %retval2 = phi i64 [ %iv.next, %loop.inc ] |
| ret i64 %retval2 |
| } |
| |
| define i64 @same_exit_block_pre_inc_use1_reverse() { |
| ; VF4IC4-LABEL: define i64 @same_exit_block_pre_inc_use1_reverse() { |
| ; VF4IC4-NEXT: entry: |
| ; VF4IC4-NEXT: [[P1:%.*]] = alloca [1024 x i8], align 1 |
| ; VF4IC4-NEXT: [[P2:%.*]] = alloca [1024 x i8], align 1 |
| ; VF4IC4-NEXT: call void @init_mem(ptr [[P1]], i64 1024) |
| ; VF4IC4-NEXT: call void @init_mem(ptr [[P2]], i64 1024) |
| ; VF4IC4-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] |
| ; VF4IC4: vector.ph: |
| ; VF4IC4-NEXT: br label [[VECTOR_BODY:%.*]] |
| ; VF4IC4: vector.body: |
| ; VF4IC4-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] |
| ; VF4IC4-NEXT: [[OFFSET_IDX:%.*]] = sub i64 1023, [[INDEX]] |
| ; VF4IC4-NEXT: [[TMP0:%.*]] = getelementptr inbounds i8, ptr [[P1]], i64 [[OFFSET_IDX]] |
| ; VF4IC4-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, ptr [[TMP0]], i32 0 |
| ; VF4IC4-NEXT: [[TMP17:%.*]] = getelementptr inbounds i8, ptr [[TMP1]], i32 -3 |
| ; VF4IC4-NEXT: [[WIDE_LOAD13:%.*]] = load <4 x i8>, ptr [[TMP17]], align 1 |
| ; VF4IC4-NEXT: [[REVERSE14:%.*]] = shufflevector <4 x i8> [[WIDE_LOAD13]], <4 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0> |
| ; VF4IC4-NEXT: [[TMP25:%.*]] = getelementptr inbounds i8, ptr [[P2]], i64 [[OFFSET_IDX]] |
| ; VF4IC4-NEXT: [[TMP26:%.*]] = getelementptr inbounds i8, ptr [[TMP25]], i32 0 |
| ; VF4IC4-NEXT: [[TMP46:%.*]] = getelementptr inbounds i8, ptr [[TMP26]], i32 -3 |
| ; VF4IC4-NEXT: [[WIDE_LOAD14:%.*]] = load <4 x i8>, ptr [[TMP46]], align 1 |
| ; VF4IC4-NEXT: [[REVERSE15:%.*]] = shufflevector <4 x i8> [[WIDE_LOAD14]], <4 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0> |
| ; VF4IC4-NEXT: [[TMP21:%.*]] = icmp ne <4 x i8> [[REVERSE14]], [[REVERSE15]] |
| ; VF4IC4-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4 |
| ; VF4IC4-NEXT: [[TMP7:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP21]]) |
| ; VF4IC4-NEXT: [[TMP8:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1020 |
| ; VF4IC4-NEXT: [[TMP9:%.*]] = or i1 [[TMP7]], [[TMP8]] |
| ; VF4IC4-NEXT: br i1 [[TMP9]], label [[MIDDLE_SPLIT:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP14:![0-9]+]] |
| ; VF4IC4: middle.split: |
| ; VF4IC4-NEXT: br i1 [[TMP7]], label [[VECTOR_EARLY_EXIT:%.*]], label [[MIDDLE_BLOCK:%.*]] |
| ; VF4IC4: middle.block: |
| ; VF4IC4-NEXT: br i1 false, label [[LOOP_END:%.*]], label [[SCALAR_PH]] |
| ; VF4IC4: vector.early.exit: |
| ; VF4IC4-NEXT: [[TMP10:%.*]] = call i64 @llvm.experimental.cttz.elts.i64.v4i1(<4 x i1> [[TMP21]], i1 true) |
| ; VF4IC4-NEXT: [[TMP11:%.*]] = add i64 [[INDEX]], [[TMP10]] |
| ; VF4IC4-NEXT: [[TMP12:%.*]] = sub i64 1023, [[TMP11]] |
| ; VF4IC4-NEXT: br label [[LOOP_END]] |
| ; VF4IC4: scalar.ph: |
| ; VF4IC4-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 3, [[MIDDLE_BLOCK]] ], [ 1023, [[ENTRY:%.*]] ] |
| ; VF4IC4-NEXT: br label [[LOOP:%.*]] |
| ; VF4IC4: loop: |
| ; VF4IC4-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[LOOP_INC:%.*]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ] |
| ; VF4IC4-NEXT: [[GEP_P1:%.*]] = getelementptr inbounds i8, ptr [[P1]], i64 [[IV]] |
| ; VF4IC4-NEXT: [[LD1:%.*]] = load i8, ptr [[GEP_P1]], align 1 |
| ; VF4IC4-NEXT: [[GEP_P2:%.*]] = getelementptr inbounds i8, ptr [[P2]], i64 [[IV]] |
| ; VF4IC4-NEXT: [[LD2:%.*]] = load i8, ptr [[GEP_P2]], align 1 |
| ; VF4IC4-NEXT: [[CMP3:%.*]] = icmp eq i8 [[LD1]], [[LD2]] |
| ; VF4IC4-NEXT: br i1 [[CMP3]], label [[LOOP_INC]], label [[LOOP_END]] |
| ; VF4IC4: loop.inc: |
| ; VF4IC4-NEXT: [[IV_NEXT]] = add i64 [[IV]], -1 |
| ; VF4IC4-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV_NEXT]], 0 |
| ; VF4IC4-NEXT: br i1 [[EXITCOND]], label [[LOOP_END]], label [[LOOP]], !llvm.loop [[LOOP15:![0-9]+]] |
| ; VF4IC4: loop.end: |
| ; VF4IC4-NEXT: [[RETVAL:%.*]] = phi i64 [ [[IV]], [[LOOP]] ], [ 1024, [[LOOP_INC]] ], [ 1024, [[MIDDLE_BLOCK]] ], [ [[TMP12]], [[VECTOR_EARLY_EXIT]] ] |
| ; VF4IC4-NEXT: ret i64 [[RETVAL]] |
| ; |
| entry: |
| %p1 = alloca [1024 x i8] |
| %p2 = alloca [1024 x i8] |
| call void @init_mem(ptr %p1, i64 1024) |
| call void @init_mem(ptr %p2, i64 1024) |
| br label %loop |
| |
| loop: |
| %iv = phi i64 [ %iv.next, %loop.inc ], [ 1023, %entry ] |
| %gep.p1 = getelementptr inbounds i8, ptr %p1, i64 %iv |
| %ld1 = load i8, ptr %gep.p1, align 1 |
| %gep.p2 = getelementptr inbounds i8, ptr %p2, i64 %iv |
| %ld2 = load i8, ptr %gep.p2, align 1 |
| %cmp3 = icmp eq i8 %ld1, %ld2 |
| br i1 %cmp3, label %loop.inc, label %loop.end |
| |
| loop.inc: |
| %iv.next = add i64 %iv, -1 |
| %exitcond = icmp eq i64 %iv.next, 0 |
| br i1 %exitcond, label %loop.end, label %loop |
| |
| loop.end: |
| %retval = phi i64 [ %iv, %loop ], [ 1024, %loop.inc ] |
| ret i64 %retval |
| } |
| |
| ; FIXME: Extracts incorrect lane if early exit is taken. |
| define i8 @same_exit_block_use_loaded_value() { |
| ; VF4IC4-LABEL: define i8 @same_exit_block_use_loaded_value() { |
| ; VF4IC4-NEXT: entry: |
| ; VF4IC4-NEXT: [[P1:%.*]] = alloca [1024 x i8], align 1 |
| ; VF4IC4-NEXT: [[P2:%.*]] = alloca [1024 x i8], align 1 |
| ; VF4IC4-NEXT: call void @init_mem(ptr [[P1]], i64 1024) |
| ; VF4IC4-NEXT: call void @init_mem(ptr [[P2]], i64 1024) |
| ; VF4IC4-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] |
| ; VF4IC4: vector.ph: |
| ; VF4IC4-NEXT: br label [[VECTOR_BODY:%.*]] |
| ; VF4IC4: vector.body: |
| ; VF4IC4-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] |
| ; VF4IC4-NEXT: [[TMP0:%.*]] = getelementptr inbounds i8, ptr [[P1]], i64 [[INDEX]] |
| ; VF4IC4-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, ptr [[TMP0]], i32 0 |
| ; VF4IC4-NEXT: [[WIDE_LOAD3:%.*]] = load <4 x i8>, ptr [[TMP1]], align 1 |
| ; VF4IC4-NEXT: [[TMP18:%.*]] = getelementptr inbounds i8, ptr [[P2]], i64 [[INDEX]] |
| ; VF4IC4-NEXT: [[TMP19:%.*]] = getelementptr inbounds i8, ptr [[TMP18]], i32 0 |
| ; VF4IC4-NEXT: [[WIDE_LOAD7:%.*]] = load <4 x i8>, ptr [[TMP19]], align 1 |
| ; VF4IC4-NEXT: [[TMP13:%.*]] = icmp ne <4 x i8> [[WIDE_LOAD3]], [[WIDE_LOAD7]] |
| ; VF4IC4-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4 |
| ; VF4IC4-NEXT: [[TMP5:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP13]]) |
| ; VF4IC4-NEXT: [[TMP6:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1024 |
| ; VF4IC4-NEXT: [[TMP7:%.*]] = or i1 [[TMP5]], [[TMP6]] |
| ; VF4IC4-NEXT: br i1 [[TMP7]], label [[MIDDLE_SPLIT:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP16:![0-9]+]] |
| ; VF4IC4: middle.split: |
| ; VF4IC4-NEXT: br i1 [[TMP5]], label [[VECTOR_EARLY_EXIT:%.*]], label [[MIDDLE_BLOCK:%.*]] |
| ; VF4IC4: middle.block: |
| ; VF4IC4-NEXT: br i1 true, label [[LOOP_END:%.*]], label [[SCALAR_PH]] |
| ; VF4IC4: vector.early.exit: |
| ; VF4IC4-NEXT: [[FIRST_ACTIVE_LANE1:%.*]] = call i64 @llvm.experimental.cttz.elts.i64.v4i1(<4 x i1> [[TMP13]], i1 true) |
| ; VF4IC4-NEXT: [[EARLY_EXIT_VALUE:%.*]] = extractelement <4 x i8> [[WIDE_LOAD3]], i64 [[FIRST_ACTIVE_LANE1]] |
| ; VF4IC4-NEXT: br label [[LOOP_END]] |
| ; VF4IC4: scalar.ph: |
| ; VF4IC4-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 1024, [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ] |
| ; VF4IC4-NEXT: br label [[LOOP:%.*]] |
| ; VF4IC4: loop: |
| ; VF4IC4-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[LOOP_INC:%.*]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ] |
| ; VF4IC4-NEXT: [[GEP_P1:%.*]] = getelementptr inbounds i8, ptr [[P1]], i64 [[IV]] |
| ; VF4IC4-NEXT: [[LD1:%.*]] = load i8, ptr [[GEP_P1]], align 1 |
| ; VF4IC4-NEXT: [[GEP_P2:%.*]] = getelementptr inbounds i8, ptr [[P2]], i64 [[IV]] |
| ; VF4IC4-NEXT: [[LD2:%.*]] = load i8, ptr [[GEP_P2]], align 1 |
| ; VF4IC4-NEXT: [[CMP3:%.*]] = icmp eq i8 [[LD1]], [[LD2]] |
| ; VF4IC4-NEXT: br i1 [[CMP3]], label [[LOOP_INC]], label [[LOOP_END]] |
| ; VF4IC4: loop.inc: |
| ; VF4IC4-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1 |
| ; VF4IC4-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV_NEXT]], 1024 |
| ; VF4IC4-NEXT: br i1 [[EXITCOND]], label [[LOOP_END]], label [[LOOP]], !llvm.loop [[LOOP17:![0-9]+]] |
| ; VF4IC4: loop.end: |
| ; VF4IC4-NEXT: [[RETVAL:%.*]] = phi i8 [ [[LD1]], [[LOOP]] ], [ -1, [[LOOP_INC]] ], [ -1, [[MIDDLE_BLOCK]] ], [ [[EARLY_EXIT_VALUE]], [[VECTOR_EARLY_EXIT]] ] |
| ; VF4IC4-NEXT: ret i8 [[RETVAL]] |
| ; |
| entry: |
| %p1 = alloca [1024 x i8] |
| %p2 = alloca [1024 x i8] |
| call void @init_mem(ptr %p1, i64 1024) |
| call void @init_mem(ptr %p2, i64 1024) |
| br label %loop |
| |
| loop: |
| %iv = phi i64 [ %iv.next, %loop.inc ], [ 0, %entry ] |
| %gep.p1 = getelementptr inbounds i8, ptr %p1, i64 %iv |
| %ld1 = load i8, ptr %gep.p1, align 1 |
| %gep.p2 = getelementptr inbounds i8, ptr %p2, i64 %iv |
| %ld2 = load i8, ptr %gep.p2, align 1 |
| %cmp3 = icmp eq i8 %ld1, %ld2 |
| br i1 %cmp3, label %loop.inc, label %loop.end |
| |
| loop.inc: |
| %iv.next = add i64 %iv, 1 |
| %exitcond = icmp eq i64 %iv.next, 1024 |
| br i1 %exitcond, label %loop.end, label %loop |
| |
| loop.end: |
| %retval = phi i8 [ %ld1, %loop ], [ -1, %loop.inc ] |
| ret i8 %retval |
| } |
| |
| ; FIXME: Extracts incorrect lane if early exit is taken. |
| define i8 @same_exit_block_reverse_use_loaded_value() { |
| ; VF4IC4-LABEL: define i8 @same_exit_block_reverse_use_loaded_value() { |
| ; VF4IC4-NEXT: entry: |
| ; VF4IC4-NEXT: [[P1:%.*]] = alloca [1024 x i8], align 1 |
| ; VF4IC4-NEXT: [[P2:%.*]] = alloca [1024 x i8], align 1 |
| ; VF4IC4-NEXT: call void @init_mem(ptr [[P1]], i64 1024) |
| ; VF4IC4-NEXT: call void @init_mem(ptr [[P2]], i64 1024) |
| ; VF4IC4-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]] |
| ; VF4IC4: vector.ph: |
| ; VF4IC4-NEXT: br label [[VECTOR_BODY:%.*]] |
| ; VF4IC4: vector.body: |
| ; VF4IC4-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ] |
| ; VF4IC4-NEXT: [[OFFSET_IDX:%.*]] = sub i64 1023, [[INDEX]] |
| ; VF4IC4-NEXT: [[TMP0:%.*]] = getelementptr inbounds i8, ptr [[P1]], i64 [[OFFSET_IDX]] |
| ; VF4IC4-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, ptr [[TMP0]], i32 0 |
| ; VF4IC4-NEXT: [[TMP8:%.*]] = getelementptr inbounds i8, ptr [[TMP1]], i32 -3 |
| ; VF4IC4-NEXT: [[WIDE_LOAD5:%.*]] = load <4 x i8>, ptr [[TMP8]], align 1 |
| ; VF4IC4-NEXT: [[REVERSE6:%.*]] = shufflevector <4 x i8> [[WIDE_LOAD5]], <4 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0> |
| ; VF4IC4-NEXT: [[TMP9:%.*]] = getelementptr inbounds i8, ptr [[P2]], i64 [[OFFSET_IDX]] |
| ; VF4IC4-NEXT: [[TMP38:%.*]] = getelementptr inbounds i8, ptr [[TMP9]], i32 0 |
| ; VF4IC4-NEXT: [[TMP17:%.*]] = getelementptr inbounds i8, ptr [[TMP38]], i32 -3 |
| ; VF4IC4-NEXT: [[WIDE_LOAD13:%.*]] = load <4 x i8>, ptr [[TMP17]], align 1 |
| ; VF4IC4-NEXT: [[REVERSE14:%.*]] = shufflevector <4 x i8> [[WIDE_LOAD13]], <4 x i8> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0> |
| ; VF4IC4-NEXT: [[TMP21:%.*]] = icmp ne <4 x i8> [[REVERSE6]], [[REVERSE14]] |
| ; VF4IC4-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4 |
| ; VF4IC4-NEXT: [[TMP25:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP21]]) |
| ; VF4IC4-NEXT: [[TMP26:%.*]] = icmp eq i64 [[INDEX_NEXT]], 1020 |
| ; VF4IC4-NEXT: [[TMP27:%.*]] = or i1 [[TMP25]], [[TMP26]] |
| ; VF4IC4-NEXT: br i1 [[TMP27]], label [[MIDDLE_SPLIT:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP18:![0-9]+]] |
| ; VF4IC4: middle.split: |
| ; VF4IC4-NEXT: br i1 [[TMP25]], label [[VECTOR_EARLY_EXIT:%.*]], label [[MIDDLE_BLOCK:%.*]] |
| ; VF4IC4: middle.block: |
| ; VF4IC4-NEXT: br i1 false, label [[LOOP_END:%.*]], label [[SCALAR_PH]] |
| ; VF4IC4: vector.early.exit: |
| ; VF4IC4-NEXT: [[FIRST_ACTIVE_LANE1:%.*]] = call i64 @llvm.experimental.cttz.elts.i64.v4i1(<4 x i1> [[TMP21]], i1 true) |
| ; VF4IC4-NEXT: [[EARLY_EXIT_VALUE:%.*]] = extractelement <4 x i8> [[REVERSE6]], i64 [[FIRST_ACTIVE_LANE1]] |
| ; VF4IC4-NEXT: br label [[LOOP_END]] |
| ; VF4IC4: scalar.ph: |
| ; VF4IC4-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 3, [[MIDDLE_BLOCK]] ], [ 1023, [[ENTRY:%.*]] ] |
| ; VF4IC4-NEXT: br label [[LOOP:%.*]] |
| ; VF4IC4: loop: |
| ; VF4IC4-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[LOOP_INC:%.*]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ] |
| ; VF4IC4-NEXT: [[GEP_P1:%.*]] = getelementptr inbounds i8, ptr [[P1]], i64 [[IV]] |
| ; VF4IC4-NEXT: [[LD1:%.*]] = load i8, ptr [[GEP_P1]], align 1 |
| ; VF4IC4-NEXT: [[GEP_P2:%.*]] = getelementptr inbounds i8, ptr [[P2]], i64 [[IV]] |
| ; VF4IC4-NEXT: [[LD2:%.*]] = load i8, ptr [[GEP_P2]], align 1 |
| ; VF4IC4-NEXT: [[CMP3:%.*]] = icmp eq i8 [[LD1]], [[LD2]] |
| ; VF4IC4-NEXT: br i1 [[CMP3]], label [[LOOP_INC]], label [[LOOP_END]] |
| ; VF4IC4: loop.inc: |
| ; VF4IC4-NEXT: [[IV_NEXT]] = add i64 [[IV]], -1 |
| ; VF4IC4-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV_NEXT]], 0 |
| ; VF4IC4-NEXT: br i1 [[EXITCOND]], label [[LOOP_END]], label [[LOOP]], !llvm.loop [[LOOP19:![0-9]+]] |
| ; VF4IC4: loop.end: |
| ; VF4IC4-NEXT: [[RETVAL:%.*]] = phi i8 [ [[LD1]], [[LOOP]] ], [ -1, [[LOOP_INC]] ], [ -1, [[MIDDLE_BLOCK]] ], [ [[EARLY_EXIT_VALUE]], [[VECTOR_EARLY_EXIT]] ] |
| ; VF4IC4-NEXT: ret i8 [[RETVAL]] |
| ; |
| entry: |
| %p1 = alloca [1024 x i8] |
| %p2 = alloca [1024 x i8] |
| call void @init_mem(ptr %p1, i64 1024) |
| call void @init_mem(ptr %p2, i64 1024) |
| br label %loop |
| |
| loop: |
| %iv = phi i64 [ %iv.next, %loop.inc ], [ 1023, %entry ] |
| %gep.p1 = getelementptr inbounds i8, ptr %p1, i64 %iv |
| %ld1 = load i8, ptr %gep.p1, align 1 |
| %gep.p2 = getelementptr inbounds i8, ptr %p2, i64 %iv |
| %ld2 = load i8, ptr %gep.p2, align 1 |
| %cmp3 = icmp eq i8 %ld1, %ld2 |
| br i1 %cmp3, label %loop.inc, label %loop.end |
| |
| loop.inc: |
| %iv.next = add i64 %iv, -1 |
| %exitcond = icmp eq i64 %iv.next, 0 |
| br i1 %exitcond, label %loop.end, label %loop |
| |
| loop.end: |
| %retval = phi i8 [ %ld1, %loop ], [ -1, %loop.inc ] |
| ret i8 %retval |
| } |