brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.9 KiB · ef2ed1f Raw
128 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: opt < %s -loop-reduce -mcpu=btver2  -S | FileCheck %s --check-prefix=JAG3; RUN: opt < %s -loop-reduce -mcpu=bdver2  -S | FileCheck %s --check-prefix=BUL4; RUN: opt < %s -loop-reduce -mcpu=haswell -S | FileCheck %s --check-prefix=HSW5 6; RUN: llc < %s                     | FileCheck %s --check-prefix=BASE7; RUN: llc < %s -mattr=macrofusion  | FileCheck %s --check-prefix=FUSE8; RUN: llc < %s -mattr=branchfusion | FileCheck %s --check-prefix=FUSE9 10target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"11target triple = "x86_64-unknown-unknown"12 13; PR35681 - https://bugs.llvm.org/show_bug.cgi?id=3568114; FIXME: If a CPU can macro-fuse a compare and branch, then we discount that15; cost in LSR and avoid generating large offsets in each memory access.16; This reduces code size and may improve decode throughput.17 18define void @maxArray(ptr noalias nocapture %x, ptr noalias nocapture readonly %y) {19; JAG-LABEL: @maxArray(20; JAG-NEXT:  entry:21; JAG-NEXT:    br label [[VECTOR_BODY:%.*]]22; JAG:       vector.body:23; JAG-NEXT:    [[LSR_IV:%.*]] = phi i64 [ [[LSR_IV_NEXT:%.*]], [[VECTOR_BODY]] ], [ -524288, [[ENTRY:%.*]] ]24; JAG-NEXT:    [[SCEVGEP2:%.*]] = getelementptr i8, ptr [[X:%.*]], i64 [[LSR_IV]]25; JAG-NEXT:    [[SCEVGEP3:%.*]] = getelementptr i8, ptr [[SCEVGEP2]], i64 52428826; JAG-NEXT:    [[SCEVGEP:%.*]] = getelementptr i8, ptr [[Y:%.*]], i64 [[LSR_IV]]27; JAG-NEXT:    [[SCEVGEP1:%.*]] = getelementptr i8, ptr [[SCEVGEP]], i64 52428828; JAG-NEXT:    [[XVAL:%.*]] = load <2 x double>, ptr [[SCEVGEP3]], align 829; JAG-NEXT:    [[YVAL:%.*]] = load <2 x double>, ptr [[SCEVGEP1]], align 830; JAG-NEXT:    [[CMP:%.*]] = fcmp ogt <2 x double> [[YVAL]], [[XVAL]]31; JAG-NEXT:    [[MAX:%.*]] = select <2 x i1> [[CMP]], <2 x double> [[YVAL]], <2 x double> [[XVAL]]32; JAG-NEXT:    store <2 x double> [[MAX]], ptr [[SCEVGEP3]], align 833; JAG-NEXT:    [[LSR_IV_NEXT]] = add nsw i64 [[LSR_IV]], 1634; JAG-NEXT:    [[DONE:%.*]] = icmp eq i64 [[LSR_IV_NEXT]], 035; JAG-NEXT:    br i1 [[DONE]], label [[EXIT:%.*]], label [[VECTOR_BODY]]36; JAG:       exit:37; JAG-NEXT:    ret void38;39; BUL-LABEL: @maxArray(40; BUL-NEXT:  entry:41; BUL-NEXT:    br label [[VECTOR_BODY:%.*]]42; BUL:       vector.body:43; BUL-NEXT:    [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]44; BUL-NEXT:    [[TMP0:%.*]] = shl nuw nsw i64 [[INDEX]], 345; BUL-NEXT:    [[SCEVGEP1:%.*]] = getelementptr i8, ptr [[X:%.*]], i64 [[TMP0]]46; BUL-NEXT:    [[TMP1:%.*]] = shl nuw nsw i64 [[INDEX]], 347; BUL-NEXT:    [[SCEVGEP:%.*]] = getelementptr i8, ptr [[Y:%.*]], i64 [[TMP1]]48; BUL-NEXT:    [[XVAL:%.*]] = load <2 x double>, ptr [[SCEVGEP1]], align 849; BUL-NEXT:    [[YVAL:%.*]] = load <2 x double>, ptr [[SCEVGEP]], align 850; BUL-NEXT:    [[CMP:%.*]] = fcmp ogt <2 x double> [[YVAL]], [[XVAL]]51; BUL-NEXT:    [[MAX:%.*]] = select <2 x i1> [[CMP]], <2 x double> [[YVAL]], <2 x double> [[XVAL]]52; BUL-NEXT:    store <2 x double> [[MAX]], ptr [[SCEVGEP1]], align 853; BUL-NEXT:    [[INDEX_NEXT]] = add i64 [[INDEX]], 254; BUL-NEXT:    [[DONE:%.*]] = icmp eq i64 [[INDEX_NEXT]], 6553655; BUL-NEXT:    br i1 [[DONE]], label [[EXIT:%.*]], label [[VECTOR_BODY]]56; BUL:       exit:57; BUL-NEXT:    ret void58;59; HSW-LABEL: @maxArray(60; HSW-NEXT:  entry:61; HSW-NEXT:    br label [[VECTOR_BODY:%.*]]62; HSW:       vector.body:63; HSW-NEXT:    [[INDEX:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]64; HSW-NEXT:    [[TMP0:%.*]] = shl nuw nsw i64 [[INDEX]], 365; HSW-NEXT:    [[SCEVGEP1:%.*]] = getelementptr i8, ptr [[X:%.*]], i64 [[TMP0]]66; HSW-NEXT:    [[TMP1:%.*]] = shl nuw nsw i64 [[INDEX]], 367; HSW-NEXT:    [[SCEVGEP:%.*]] = getelementptr i8, ptr [[Y:%.*]], i64 [[TMP1]]68; HSW-NEXT:    [[XVAL:%.*]] = load <2 x double>, ptr [[SCEVGEP1]], align 869; HSW-NEXT:    [[YVAL:%.*]] = load <2 x double>, ptr [[SCEVGEP]], align 870; HSW-NEXT:    [[CMP:%.*]] = fcmp ogt <2 x double> [[YVAL]], [[XVAL]]71; HSW-NEXT:    [[MAX:%.*]] = select <2 x i1> [[CMP]], <2 x double> [[YVAL]], <2 x double> [[XVAL]]72; HSW-NEXT:    store <2 x double> [[MAX]], ptr [[SCEVGEP1]], align 873; HSW-NEXT:    [[INDEX_NEXT]] = add i64 [[INDEX]], 274; HSW-NEXT:    [[DONE:%.*]] = icmp eq i64 [[INDEX_NEXT]], 6553675; HSW-NEXT:    br i1 [[DONE]], label [[EXIT:%.*]], label [[VECTOR_BODY]]76; HSW:       exit:77; HSW-NEXT:    ret void78;79; BASE-LABEL: maxArray:80; BASE:       # %bb.0: # %entry81; BASE-NEXT:    movq $-524288, %rax # imm = 0xFFF8000082; BASE-NEXT:    .p2align 483; BASE-NEXT:  .LBB0_1: # %vector.body84; BASE-NEXT:    # =>This Inner Loop Header: Depth=185; BASE-NEXT:    movupd 524288(%rdi,%rax), %xmm086; BASE-NEXT:    movupd 524288(%rsi,%rax), %xmm187; BASE-NEXT:    maxpd %xmm0, %xmm188; BASE-NEXT:    movupd %xmm1, 524288(%rdi,%rax)89; BASE-NEXT:    addq $16, %rax90; BASE-NEXT:    jne .LBB0_191; BASE-NEXT:  # %bb.2: # %exit92; BASE-NEXT:    retq93; FUSE-LABEL: maxArray:94; FUSE:       # %bb.0: # %entry95; FUSE-NEXT:    xorl %eax, %eax96; FUSE-NEXT:    .p2align 497; FUSE-NEXT:  .LBB0_1: # %vector.body98; FUSE-NEXT:    # =>This Inner Loop Header: Depth=199; FUSE-NEXT:    movupd (%rdi,%rax,8), %xmm0100; FUSE-NEXT:    movupd (%rsi,%rax,8), %xmm1101; FUSE-NEXT:    maxpd %xmm0, %xmm1102; FUSE-NEXT:    movupd %xmm1, (%rdi,%rax,8)103; FUSE-NEXT:    addq $2, %rax104; FUSE-NEXT:    cmpq $65536, %rax # imm = 0x10000105; FUSE-NEXT:    jne .LBB0_1106; FUSE-NEXT:  # %bb.2: # %exit107; FUSE-NEXT:    retq108entry:109  br label %vector.body110 111vector.body:112  %index = phi i64 [ 0, %entry ], [ %index.next, %vector.body ]113  %gepx = getelementptr inbounds double, ptr %x, i64 %index114  %gepy = getelementptr inbounds double, ptr %y, i64 %index115  %xval = load <2 x double>, ptr %gepx, align 8116  %yval = load <2 x double>, ptr %gepy, align 8117  %cmp = fcmp ogt <2 x double> %yval, %xval118  %max = select <2 x i1> %cmp, <2 x double> %yval, <2 x double> %xval119  store <2 x double> %max, ptr %gepx, align 8120  %index.next = add i64 %index, 2121  %done = icmp eq i64 %index.next, 65536122  br i1 %done, label %exit, label %vector.body123 124exit:125  ret void126}127 128