1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
llvm-mirror/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll
David Blaikie ab043ff680 [opaque pointer type] Add textual IR support for explicit type parameter to load instruction
Essentially the same as the GEP change in r230786.

A similar migration script can be used to update test cases, though a few more
test case improvements/changes were required this time around: (r229269-r229278)

import fileinput
import sys
import re

pat = re.compile(r"((?:=|:|^)\s*load (?:atomic )?(?:volatile )?(.*?))(| addrspace\(\d+\) *)\*($| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$)")

for line in sys.stdin:
  sys.stdout.write(re.sub(pat, r"\1, \2\3*\4", line))

Reviewers: rafael, dexonsmith, grosser

Differential Revision: http://reviews.llvm.org/D7649

llvm-svn: 230794
2015-02-27 21:17:42 +00:00

65 lines
2.0 KiB
LLVM

; RUN: opt -S -instcombine < %s | FileCheck %s
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32"
target triple = "i386-apple-darwin10.0.0"
; CHECK-LABEL: define void @fu1(
define void @fu1(i32 %parm) nounwind ssp {
%1 = alloca i32, align 4
; CHECK: alloca double*
%ptr = alloca double*, align 4
store i32 %parm, i32* %1, align 4
store double* null, double** %ptr, align 4
%2 = load i32, i32* %1, align 4
%3 = icmp ne i32 %2, 0
br i1 %3, label %4, label %10
; <label>:4 ; preds = %0
%5 = load i32, i32* %1, align 4
%6 = shl nsw i32 %5, 3
; With "nsw", the alloca and its bitcast can be fused:
%7 = add nsw i32 %6, 2048
; CHECK: alloca double
%8 = alloca i8, i32 %7
%9 = bitcast i8* %8 to double*
; CHECK-NEXT: store double*
store double* %9, double** %ptr, align 4
br label %10
; <label>:10 ; preds = %4, %0
%11 = load double*, double** %ptr, align 4
call void @bar(double* %11)
; CHECK: ret
ret void
}
declare void @bar(double*)
; CHECK-LABEL: define void @fu2(
define void @fu2(i32 %parm) nounwind ssp {
%1 = alloca i32, align 4
%ptr = alloca double*, align 4
store i32 %parm, i32* %1, align 4
store double* null, double** %ptr, align 4
%2 = load i32, i32* %1, align 4
%3 = icmp ne i32 %2, 0
br i1 %3, label %4, label %10
; <label>:4 ; preds = %0
%5 = load i32, i32* %1, align 4
%6 = mul nsw i32 %5, 8
; Without "nsw", the alloca and its bitcast cannot be fused:
%7 = add i32 %6, 2048
; CHECK: alloca i8
%8 = alloca i8, i32 %7
; CHECK-NEXT: bitcast double**
; CHECK-NEXT: store i8*
%9 = bitcast i8* %8 to double*
store double* %9, double** %ptr, align 4
br label %10
; <label>:10 ; preds = %4, %0
%11 = load double*, double** %ptr, align 4
call void @bar(double* %11)
ret void
}