Files
clang-p2996/llvm/test/Transforms/LoopVersioning/lcssa.ll
Florian Hahn e844f05397 [LoopUtils] Simplify addRuntimeCheck to return a single value.
This simplifies the return value of addRuntimeCheck from a pair of
instructions to a single `Value *`.

The existing users of addRuntimeChecks were ignoring the first element
of the pair, hence there is not reason to track FirstInst and return
it.

Additionally all users of addRuntimeChecks use the second returned
`Instruction *` just as `Value *`, so there is no need to return an
`Instruction *`. Therefore there is no need to create a redundant
dummy `and X, true` instruction any longer.

Effectively this change should not impact the generated code because the
redundant AND will be folded by later optimizations. But it is easy to
avoid creating it in the first place and it allows more accurately
estimating the cost of the runtime checks.
2021-10-18 18:03:09 +01:00

73 lines
2.3 KiB
LLVM

; RUN: opt -basic-aa -loop-versioning -S < %s | FileCheck %s
target triple = "x86_64-unknown-linux-gnu"
define void @fill(i8** %ls1.20, i8** %ls2.21, i8* %cse3.22) {
; CHECK: bb1.lver.check:
; CHECK: br i1 %found.conflict, label %bb1.ph.lver.orig, label %bb1.ph
bb1.ph:
%ls1.20.promoted = load i8*, i8** %ls1.20
%ls2.21.promoted = load i8*, i8** %ls2.21
br label %bb1
bb1:
%_tmp302 = phi i8* [ %ls2.21.promoted, %bb1.ph ], [ %_tmp30, %bb1 ]
%_tmp281 = phi i8* [ %ls1.20.promoted, %bb1.ph ], [ %_tmp28, %bb1 ]
%_tmp14 = getelementptr i8, i8* %_tmp281, i16 -1
%_tmp15 = load i8, i8* %_tmp14
%add = add i8 %_tmp15, 1
store i8 %add, i8* %_tmp281
store i8 %add, i8* %_tmp302
%_tmp28 = getelementptr i8, i8* %_tmp281, i16 1
%_tmp30 = getelementptr i8, i8* %_tmp302, i16 1
br i1 false, label %bb1, label %bb3.loopexit
bb3.loopexit:
%_tmp30.lcssa = phi i8* [ %_tmp30, %bb1 ]
%_tmp15.lcssa = phi i8 [ %_tmp15, %bb1 ]
%_tmp28.lcssa = phi i8* [ %_tmp28, %bb1 ]
store i8* %_tmp28.lcssa, i8** %ls1.20
store i8 %_tmp15.lcssa, i8* %cse3.22
store i8* %_tmp30.lcssa, i8** %ls2.21
br label %bb3
bb3:
ret void
}
define void @fill_no_null_opt(i8** %ls1.20, i8** %ls2.21, i8* %cse3.22) #0 {
; CHECK-LABEL: fill_no_null_opt(
; CHECK: bb1.lver.check:
; CHECK: %lver.safe = or i1 %found.conflict, %{{.*}}
; CHECK: br i1 %lver.safe, label %bb1.ph.lver.orig, label %bb1.ph
bb1.ph:
%ls1.20.promoted = load i8*, i8** %ls1.20
%ls2.21.promoted = load i8*, i8** %ls2.21
br label %bb1
bb1:
%_tmp302 = phi i8* [ %ls2.21.promoted, %bb1.ph ], [ %_tmp30, %bb1 ]
%_tmp281 = phi i8* [ %ls1.20.promoted, %bb1.ph ], [ %_tmp28, %bb1 ]
%_tmp14 = getelementptr i8, i8* %_tmp281, i16 -1
%_tmp15 = load i8, i8* %_tmp14
%add = add i8 %_tmp15, 1
store i8 %add, i8* %_tmp281
store i8 %add, i8* %_tmp302
%_tmp28 = getelementptr i8, i8* %_tmp281, i16 1
%_tmp30 = getelementptr i8, i8* %_tmp302, i16 1
br i1 false, label %bb1, label %bb3.loopexit
bb3.loopexit:
%_tmp30.lcssa = phi i8* [ %_tmp30, %bb1 ]
%_tmp15.lcssa = phi i8 [ %_tmp15, %bb1 ]
%_tmp28.lcssa = phi i8* [ %_tmp28, %bb1 ]
store i8* %_tmp28.lcssa, i8** %ls1.20
store i8 %_tmp15.lcssa, i8* %cse3.22
store i8* %_tmp30.lcssa, i8** %ls2.21
br label %bb3
bb3:
ret void
}
attributes #0 = { null_pointer_is_valid }