llvm-6502/test/Assembler/ConstantExprFold.ll
David Blaikie 5a70dd1d82 [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:])

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232184 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13 18:20:45 +00:00

33 lines
1.6 KiB
LLVM

; This test checks to make sure that constant exprs fold in some simple
; situations
; RUN: llvm-as < %s | llvm-dis | not grep "("
; RUN: verify-uselistorder %s
@A = global i64 0
global i64* inttoptr (i64 add (i64 ptrtoint (i64* @A to i64), i64 0) to i64*) ; X + 0 == X
global i64* inttoptr (i64 sub (i64 ptrtoint (i64* @A to i64), i64 0) to i64*) ; X - 0 == X
global i64* inttoptr (i64 mul (i64 ptrtoint (i64* @A to i64), i64 0) to i64*) ; X * 0 == 0
global i64* inttoptr (i64 sdiv (i64 ptrtoint (i64* @A to i64), i64 1) to i64*) ; X / 1 == X
global i64* inttoptr (i64 srem (i64 ptrtoint (i64* @A to i64), i64 1) to i64*) ; X % 1 == 0
global i64* inttoptr (i64 and (i64 ptrtoint (i64* @A to i64), i64 0) to i64*) ; X & 0 == 0
global i64* inttoptr (i64 and (i64 ptrtoint (i64* @A to i64), i64 -1) to i64*) ; X & -1 == X
global i64 or (i64 ptrtoint (i64* @A to i64), i64 -1) ; X | -1 == -1
global i64* inttoptr (i64 xor (i64 ptrtoint (i64* @A to i64), i64 0) to i64*) ; X ^ 0 == X
%Ty = type { i32, i32 }
@B = external global %Ty
global i1 icmp slt (i64* @A, i64* getelementptr (i64, i64* @A, i64 1)) ; true
global i1 icmp ult (i64* @A, i64* getelementptr (i64, i64* @A, i64 1)) ; true
global i1 icmp slt (i64* @A, i64* getelementptr (i64, i64* @A, i64 0)) ; false
global i1 icmp slt (i32* getelementptr (%Ty, %Ty* @B, i64 0, i32 0),
i32* getelementptr (%Ty, %Ty* @B, i64 0, i32 1)) ; true
;global i1 icmp ne (i64* @A, i64* bitcast (%Ty* @B to i64*)) ; true
; PR2206
@cons = weak global i32 0, align 8 ; <i32*> [#uses=1]
global i64 and (i64 ptrtoint (i32* @cons to i64), i64 7)