1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/test/Transforms/LoopLoadElim/pr-48150.ll
Max Kazantsev 6165ecd19b [LoopLoadElim] Make sure all loops are in simplify form. PR48150
LoopLoadElim may end up expanding an AddRec from a loop
which is not the current loop. This loop may not be in simplify
form. We figure it out after the no-return point, so cannot bail
in this case.

AddRec requires simplify form to expand. The only way to ensure
this does not crash is to simplify all loops beforehand.

The issue only exists in new PM. Old PM requests LoopSimplify
required pass and it simplifies all loops before the opt begins.

Differential Revision: https://reviews.llvm.org/D91525
Reviewed By: asbirlea, aeubanks
2020-11-26 10:51:11 +07:00

55 lines
2.0 KiB
LLVM

; RUN: opt -passes=loop-load-elim -S < %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-ni:1-p2:32:8:8:32-ni:2"
target triple = "x86_64-unknown-linux-gnu"
define void @test() {
; CHECK-LABEL: test
bb:
br i1 undef, label %bb1, label %bb2
bb1: ; preds = %bb
ret void
bb2: ; preds = %bb29, %bb
%tmp = phi i64 [ %tmp30, %bb29 ], [ 2, %bb ]
%tmp3 = add nuw nsw i64 %tmp, 99
br label %bb4
bb4: ; preds = %bb4, %bb2
%tmp5 = phi i64 [ %tmp9, %bb4 ], [ 1, %bb2 ]
%tmp6 = phi i32 [ %tmp10, %bb4 ], [ undef, %bb2 ]
%tmp7 = trunc i64 %tmp5 to i32
%tmp8 = add i32 %tmp6, %tmp7
%tmp9 = add nuw nsw i64 %tmp5, 1
%tmp10 = add i32 %tmp8, -1
%tmp11 = icmp ugt i64 %tmp3, %tmp5
br i1 %tmp11, label %bb4, label %bb12
bb12: ; preds = %bb4
%tmp13 = sext i32 %tmp8 to i64
%tmp14 = add i64 0, %tmp13
%tmp15 = mul i64 %tmp14, undef
%tmp16 = add i64 %tmp15, 83
%tmp17 = and i64 %tmp16, -2
br label %bb18
bb18: ; preds = %bb18, %bb12
%tmp19 = phi i64 [ 0, %bb12 ], [ %tmp27, %bb18 ]
%tmp20 = add i64 %tmp19, 3
%tmp21 = add i64 %tmp19, 5
%tmp22 = getelementptr inbounds i32, i32 addrspace(1)* undef, i64 %tmp20
%tmp23 = bitcast i32 addrspace(1)* %tmp22 to <2 x i32> addrspace(1)*
%tmp24 = load <2 x i32>, <2 x i32> addrspace(1)* %tmp23, align 4
%tmp25 = getelementptr inbounds i32, i32 addrspace(1)* undef, i64 %tmp21
%tmp26 = bitcast i32 addrspace(1)* %tmp25 to <2 x i32> addrspace(1)*
store <2 x i32> undef, <2 x i32> addrspace(1)* %tmp26, align 4
%tmp27 = add i64 %tmp19, 2
%tmp28 = icmp eq i64 %tmp27, %tmp17
br i1 %tmp28, label %bb29, label %bb18
bb29: ; preds = %bb18
%tmp30 = add nuw nsw i64 %tmp, 1
br label %bb2
}