1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 20:12:56 +02:00
llvm-mirror/test/Transforms/IndVarSimplify/eliminate-max.ll
David Blaikie 3ea2df7c7b [opaque pointer type] Add textual IR support for explicit type parameter to gep operator
Similar to gep (r230786) and load (r230794) changes.

Similar migration script can be used to update test cases, which
successfully migrated all of LLVM and Polly, but about 4 test cases
needed manually changes in Clang.

(this script will read the contents of stdin and massage it into stdout
- wrap it in the 'apply.sh' script shown in previous commits + xargs to
apply it over a large set of test cases)

import fileinput
import sys
import re

rep = re.compile(r"(getelementptr(?:\s+inbounds)?\s*\()((<\d*\s+x\s+)?([^@]*?)(|\s*addrspace\(\d+\))\s*\*(?(3)>)\s*)(?=$|%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|zeroinitializer|<|\[\[[a-zA-Z]|\{\{)", re.MULTILINE | re.DOTALL)

def conv(match):
  line = match.group(1)
  line += match.group(4)
  line += ", "
  line += match.group(2)
  return line

line = sys.stdin.read()
off = 0
for match in re.finditer(rep, line):
  sys.stdout.write(line[off:match.start()])
  sys.stdout.write(conv(match))
  off = match.end()
sys.stdout.write(line[off:])

llvm-svn: 232184
2015-03-13 18:20:45 +00:00

53 lines
2.3 KiB
LLVM

; RUN: opt < %s -S -indvars | grep "= icmp" | count 3
; PR4914.ll
; Indvars should be able to do range analysis and eliminate icmps.
; There are two here which cannot be eliminated.
; There's one that icmp which can be eliminated and which indvars currently
; cannot eliminate, because it requires analyzing more than just the
; range of the induction variable.
@0 = private constant [4 x i8] c"%d\0A\00", align 1 ; <[4 x i8]*> [#uses=1]
define i32 @main() nounwind {
bb:
br label %bb1
bb1: ; preds = %bb14, %bb
%t = phi i32 [ 0, %bb ], [ %t19, %bb14 ] ; <i32> [#uses=5]
%t2 = phi i32 [ 0, %bb ], [ %t18, %bb14 ] ; <i32> [#uses=1]
%t3 = icmp slt i32 %t, 0 ; <i1> [#uses=1]
br i1 %t3, label %bb7, label %bb4
bb4: ; preds = %bb1
%t5 = icmp sgt i32 %t, 255 ; <i1> [#uses=1]
%t6 = select i1 %t5, i32 255, i32 %t ; <i32> [#uses=1]
br label %bb7
bb7: ; preds = %bb4, %bb1
%t8 = phi i32 [ %t6, %bb4 ], [ 0, %bb1 ] ; <i32> [#uses=1]
%t9 = sub i32 0, %t ; <i32> [#uses=3]
%t10 = icmp slt i32 %t9, 0 ; <i1> [#uses=1]
br i1 %t10, label %bb14, label %bb11
bb11: ; preds = %bb7
%t12 = icmp sgt i32 %t9, 255 ; <i1> [#uses=1]
%t13 = select i1 %t12, i32 255, i32 %t9 ; <i32> [#uses=1]
br label %bb14
bb14: ; preds = %bb11, %bb7
%t15 = phi i32 [ %t13, %bb11 ], [ 0, %bb7 ] ; <i32> [#uses=1]
%t16 = add nsw i32 %t2, 255 ; <i32> [#uses=1]
%t17 = add nsw i32 %t16, %t8 ; <i32> [#uses=1]
%t18 = add nsw i32 %t17, %t15 ; <i32> [#uses=2]
%t19 = add nsw i32 %t, 1 ; <i32> [#uses=2]
%t20 = icmp slt i32 %t19, 1000000000 ; <i1> [#uses=1]
br i1 %t20, label %bb1, label %bb21
bb21: ; preds = %bb14
%t22 = call i32 (i8*, ...)* @printf(i8* noalias getelementptr inbounds ([4 x i8], [4 x i8]* @0, i32 0, i32 0), i32 %t18) nounwind
ret i32 0
}
declare i32 @printf(i8* noalias nocapture, ...) nounwind