llvm-project/llvm/test/CodeGen/X86/hoist-invariant-load.ll

92 lines
3.6 KiB
LLVM
Raw Normal View History

; REQUIRES: asserts
; RUN: llc -mcpu=haswell < %s -stats -O2 2>&1 | grep "7 machinelicm.*hoisted"
; For test:
; 2 invariant loads, 1 for OBJC_SELECTOR_REFERENCES_
; and 1 for objc_msgSend from the GOT
; For test_multi_def:
; 2 invariant load (full multiply, both loads should be hoisted.)
; For test_div_def:
; 2 invariant load (full divide, both loads should be hoisted.) 1 additional instruction for a zeroing edx that gets hoisted and then rematerialized.
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.7.2"
@"\01L_OBJC_METH_VAR_NAME_" = internal global [4 x i8] c"foo\00", section "__TEXT,__objc_methname,cstring_literals", align 1
@"\01L_OBJC_SELECTOR_REFERENCES_" = internal global i8* getelementptr inbounds ([4 x i8], [4 x i8]* @"\01L_OBJC_METH_VAR_NAME_", i64 0, i64 0), section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
@"\01L_OBJC_IMAGE_INFO" = internal constant [2 x i32] [i32 0, i32 16], section "__DATA, __objc_imageinfo, regular, no_dead_strip"
@llvm.used = appending global [3 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @"\01L_OBJC_METH_VAR_NAME_", i32 0, i32 0), i8* bitcast (i8** @"\01L_OBJC_SELECTOR_REFERENCES_" to i8*), i8* bitcast ([2 x i32]* @"\01L_OBJC_IMAGE_INFO" to i8*)], section "llvm.metadata"
define void @test(i8* %x) uwtable ssp {
entry:
br label %for.body
for.body: ; preds = %for.body, %entry
%i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
%0 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_", align 8, !invariant.load !0
%call = tail call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* %x, i8* %0)
%inc = add i32 %i.01, 1
%exitcond = icmp eq i32 %inc, 10000
br i1 %exitcond, label %for.end, label %for.body
for.end: ; preds = %for.body
ret void
}
declare i8* @objc_msgSend(i8*, i8*, ...) nonlazybind
define void @test_multi_def(i64* dereferenceable(8) %x1,
i64* dereferenceable(8) %x2,
i128* %y, i64 %count) nounwind {
entry:
br label %for.body
for.check:
%inc = add nsw i64 %i, 1
%done = icmp sge i64 %inc, %count
br i1 %done, label %exit, label %for.body
for.body:
%i = phi i64 [ 0, %entry ], [ %inc, %for.check ]
%x1_load = load i64, i64* %x1, align 8, !invariant.load !0
%x1_zext = zext i64 %x1_load to i128
%x2_load = load i64, i64* %x2, align 8, !invariant.load !0
%x2_zext = zext i64 %x2_load to i128
%x_prod = mul i128 %x1_zext, %x2_zext
%y_elem = getelementptr inbounds i128, i128* %y, i64 %i
%y_load = load i128, i128* %y_elem, align 8
%y_plus = add i128 %x_prod, %y_load
store i128 %y_plus, i128* %y_elem, align 8
br label %for.check
exit:
ret void
}
define void @test_div_def(i32* dereferenceable(8) %x1,
i32* dereferenceable(8) %x2,
i32* %y, i32 %count) nounwind {
entry:
br label %for.body
for.check:
%inc = add nsw i32 %i, 1
%done = icmp sge i32 %inc, %count
br i1 %done, label %exit, label %for.body
for.body:
%i = phi i32 [ 0, %entry ], [ %inc, %for.check ]
%x1_load = load i32, i32* %x1, align 8, !invariant.load !0
%x2_load = load i32, i32* %x2, align 8, !invariant.load !0
%x_quot = udiv i32 %x1_load, %x2_load
%y_elem = getelementptr inbounds i32, i32* %y, i32 %i
%y_load = load i32, i32* %y_elem, align 8
%y_plus = add i32 %x_quot, %y_load
store i32 %y_plus, i32* %y_elem, align 8
br label %for.check
exit:
ret void
}
IR: Make metadata typeless in assembly Now that `Metadata` is typeless, reflect that in the assembly. These are the matching assembly changes for the metadata/value split in r223802. - Only use the `metadata` type when referencing metadata from a call intrinsic -- i.e., only when it's used as a `Value`. - Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode` when referencing it from call intrinsics. So, assembly like this: define @foo(i32 %v) { call void @llvm.foo(metadata !{i32 %v}, metadata !0) call void @llvm.foo(metadata !{i32 7}, metadata !0) call void @llvm.foo(metadata !1, metadata !0) call void @llvm.foo(metadata !3, metadata !0) call void @llvm.foo(metadata !{metadata !3}, metadata !0) ret void, !bar !2 } !0 = metadata !{metadata !2} !1 = metadata !{i32* @global} !2 = metadata !{metadata !3} !3 = metadata !{} turns into this: define @foo(i32 %v) { call void @llvm.foo(metadata i32 %v, metadata !0) call void @llvm.foo(metadata i32 7, metadata !0) call void @llvm.foo(metadata i32* @global, metadata !0) call void @llvm.foo(metadata !3, metadata !0) call void @llvm.foo(metadata !{!3}, metadata !0) ret void, !bar !2 } !0 = !{!2} !1 = !{i32* @global} !2 = !{!3} !3 = !{} I wrote an upgrade script that handled almost all of the tests in llvm and many of the tests in cfe (even handling many `CHECK` lines). I've attached it (or will attach it in a moment if you're speedy) to PR21532 to help everyone update their out-of-tree testcases. This is part of PR21532. llvm-svn: 224257
2014-12-16 03:07:53 +08:00
!0 = !{}