mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 04:30:12 +00:00
e027d74733
Summary: This change teaches isImpliedCond to infer things like "X sgt 0" => "X - 1 sgt -1". The `ConstantRange` class has the logic to do the heavy lifting, this change simply gets ScalarEvolution to exploit that when reasonable. Depends on D8345 Reviewers: atrick Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8346 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232576 91177308-0d34-0410-b5e6-96231b3b80d8
31 lines
755 B
LLVM
31 lines
755 B
LLVM
; RUN: opt -indvars -S < %s | FileCheck %s
|
|
|
|
define void @infer_via_ranges(i32 *%arr, i32 %n) {
|
|
; CHECK-LABEL: @infer_via_ranges
|
|
entry:
|
|
%first.itr.check = icmp sgt i32 %n, 0
|
|
%start = sub i32 %n, 1
|
|
br i1 %first.itr.check, label %loop, label %exit
|
|
|
|
loop:
|
|
; CHECK-LABEL: loop:
|
|
%idx = phi i32 [ %start, %entry ] , [ %idx.dec, %in.bounds ]
|
|
%idx.dec = sub i32 %idx, 1
|
|
%abc = icmp sge i32 %idx, 0
|
|
; CHECK: br i1 true, label %in.bounds, label %out.of.bounds
|
|
br i1 %abc, label %in.bounds, label %out.of.bounds
|
|
|
|
in.bounds:
|
|
; CHECK-LABEL: in.bounds:
|
|
%addr = getelementptr i32, i32* %arr, i32 %idx
|
|
store i32 0, i32* %addr
|
|
%next = icmp sgt i32 %idx.dec, -1
|
|
br i1 %next, label %loop, label %exit
|
|
|
|
out.of.bounds:
|
|
ret void
|
|
|
|
exit:
|
|
ret void
|
|
}
|