1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00
llvm-mirror/test/Transforms/IndVarSimplify/canonicalize-cmp.ll
Eric Christopher a62270de2c Revert "Temporarily Revert "Add basic loop fusion pass.""
The reversion apparently deleted the test/Transforms directory.

Will be re-reverting again.

llvm-svn: 358552
2019-04-17 04:52:47 +00:00

99 lines
1.8 KiB
LLVM

; RUN: opt -S -indvars < %s | FileCheck %s
; Check that we replace signed comparisons between non-negative values with
; unsigned comparisons if we can.
target datalayout = "n8:16:32:64"
define i32 @test_01(i32 %a, i32 %b, i32* %p) {
; CHECK-LABEL: @test_01(
; CHECK-NOT: icmp slt
; CHECK: %cmp1 = icmp ult i32 %iv, 100
; CHECK: %cmp2 = icmp ult i32 %iv, 100
; CHECK-NOT: %cmp3
; CHECK: %exitcond = icmp ne i32 %iv.next, 1000
entry:
br label %loop.entry
loop.entry:
%iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.be ]
%cmp1 = icmp slt i32 %iv, 100
br i1 %cmp1, label %b1, label %b2
b1:
store i32 %iv, i32* %p
br label %merge
b2:
store i32 %a, i32* %p
br label %merge
merge:
%cmp2 = icmp ult i32 %iv, 100
br i1 %cmp2, label %b3, label %b4
b3:
store i32 %iv, i32* %p
br label %loop.be
b4:
store i32 %b, i32* %p
br label %loop.be
loop.be:
%iv.next = add i32 %iv, 1
%cmp3 = icmp slt i32 %iv.next, 1000
br i1 %cmp3, label %loop.entry, label %exit
exit:
ret i32 %iv
}
define i32 @test_02(i32 %a, i32 %b, i32* %p) {
; CHECK-LABEL: @test_02(
; CHECK-NOT: icmp sgt
; CHECK: %cmp1 = icmp ugt i32 100, %iv
; CHECK: %cmp2 = icmp ugt i32 100, %iv
; CHECK-NOT: %cmp3
; CHECK: %exitcond = icmp ne i32 %iv.next, 1000
entry:
br label %loop.entry
loop.entry:
%iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.be ]
%cmp1 = icmp sgt i32 100, %iv
br i1 %cmp1, label %b1, label %b2
b1:
store i32 %iv, i32* %p
br label %merge
b2:
store i32 %a, i32* %p
br label %merge
merge:
%cmp2 = icmp ugt i32 100, %iv
br i1 %cmp2, label %b3, label %b4
b3:
store i32 %iv, i32* %p
br label %loop.be
b4:
store i32 %b, i32* %p
br label %loop.be
loop.be:
%iv.next = add i32 %iv, 1
%cmp3 = icmp sgt i32 1000, %iv.next
br i1 %cmp3, label %loop.entry, label %exit
exit:
ret i32 %iv
}