File: masked-memory-ops.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (53 lines) | stat: -rw-r--r-- 2,712 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -O2 -S                                        | FileCheck %s
; RUN: opt < %s -passes="default<O2>" -S | FileCheck %s

target triple = "x86_64--"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

declare void @llvm.x86.avx.maskstore.ps.256(ptr, <8 x i32>, <8 x float>) #0
declare void @llvm.masked.store.v8f32.p0(<8 x float>, ptr, i32, <8 x i1>)

; PR11210: If we have been able to replace a AVX/AVX2 masked store with a
; generic masked store intrinsic, then we should be able to remove dead
; masked stores.

define void @PR11210_v8f32_maskstore_maskstore(ptr %ptr, <8 x float> %x, <8 x float> %y, <8 x i32> %src) {
; CHECK-LABEL: @PR11210_v8f32_maskstore_maskstore(
; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt <8 x i32> [[SRC:%.*]], zeroinitializer
; CHECK-NEXT:    tail call void @llvm.masked.store.v8f32.p0(<8 x float> [[Y:%.*]], ptr [[PTR:%.*]], i32 1, <8 x i1> [[CMP]])
; CHECK-NEXT:    ret void
;
  %cmp = icmp sgt <8 x i32> %src, zeroinitializer
  %mask = sext <8 x i1> %cmp to <8 x i32>
  call void @llvm.x86.avx.maskstore.ps.256(ptr %ptr, <8 x i32> %mask, <8 x float> %x)
  call void @llvm.x86.avx.maskstore.ps.256(ptr %ptr, <8 x i32> %mask, <8 x float> %y)
  ret void
}

; The contents of %mask are unknown so we don't replace this with a generic masked.store.
define void @PR11210_v8f32_maskstore_maskstore_raw_mask(ptr %ptr, <8 x float> %x, <8 x float> %y, <8 x i32> %mask) {
; CHECK-LABEL: @PR11210_v8f32_maskstore_maskstore_raw_mask(
; CHECK-NEXT:    tail call void @llvm.x86.avx.maskstore.ps.256(ptr [[PTR:%.*]], <8 x i32> [[MASK:%.*]], <8 x float> [[X:%.*]])
; CHECK-NEXT:    tail call void @llvm.x86.avx.maskstore.ps.256(ptr [[PTR]], <8 x i32> [[MASK]], <8 x float> [[Y:%.*]])
; CHECK-NEXT:    ret void
;
  call void @llvm.x86.avx.maskstore.ps.256(ptr %ptr, <8 x i32> %mask, <8 x float> %x)
  call void @llvm.x86.avx.maskstore.ps.256(ptr %ptr, <8 x i32> %mask, <8 x float> %y)
  ret void
}

; Mix AVX and generic masked stores.
define void @PR11210_v8f32_mstore_maskstore(ptr %ptr, <8 x float> %x, <8 x float> %y, <8 x i32> %src) {
; CHECK-LABEL: @PR11210_v8f32_mstore_maskstore(
; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt <8 x i32> [[SRC:%.*]], zeroinitializer
; CHECK-NEXT:    tail call void @llvm.masked.store.v8f32.p0(<8 x float> [[Y:%.*]], ptr [[PTR:%.*]], i32 1, <8 x i1> [[CMP]])
; CHECK-NEXT:    ret void
;
  %cmp = icmp sgt <8 x i32> %src, zeroinitializer
  %mask = sext <8 x i1> %cmp to <8 x i32>
  tail call void @llvm.masked.store.v8f32.p0(<8 x float> %x, ptr %ptr, i32 1, <8 x i1> %cmp)
  call void @llvm.x86.avx.maskstore.ps.256(ptr %ptr, <8 x i32> %mask, <8 x float> %y)
  ret void
}