File: amdgpu-codegenprepare-foldnegate.ll

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (66 lines) | stat: -rw-r--r-- 2,496 bytes parent folder | download | duplicates (2)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
; RUN: opt -mtriple=amdgcn-amd-amdhsa -amdgpu-codegenprepare -verify -S %s -o - | FileCheck %s

declare i1 @llvm.amdgcn.class.f32(float, i32) nounwind readnone
declare i1 @llvm.amdgcn.class.f64(double, i32) nounwind readnone

; Trivial case, xor instruction should be removed and
; the second argument of the intrinsic call should be
; bitwise-negated
; CHECK: @fold_negate_intrinsic_test_mask
; CHECK: %1 = call i1 @llvm.amdgcn.class.f32(float %x, i32 1018)
define i1 @fold_negate_intrinsic_test_mask(float %x) nounwind {
  %1 = call i1 @llvm.amdgcn.class.f32(float %x, i32 5)
  %2 = xor i1 %1, -1
  ret i1 %2
}

; Trivial case, xor instruction should be removed and
; the second argument of the intrinsic call should be
; bitwise-negated
; CHECK: @fold_negate_intrinsic_test_mask_dbl
; CHECK: %1 = call i1 @llvm.amdgcn.class.f64(double %x, i32 1018)
define i1 @fold_negate_intrinsic_test_mask_dbl(double %x) nounwind {
  %1 = call i1 @llvm.amdgcn.class.f64(double %x, i32 5)
  %2 = xor i1 %1, -1
  ret i1 %2
}

; Negative test: should not transform for variable test masks
; CHECK: @fold_negate_intrinsic_test_mask_neg_var
; CHECK: %[[X0:.*]] = alloca i32
; CHECK: %[[X1:.*]] = load i32, ptr addrspace(5) %[[X0]]
; CHECK: call i1 @llvm.amdgcn.class.f32(float %x, i32 %[[X1]])
; CHECK: xor
define i1 @fold_negate_intrinsic_test_mask_neg_var(float %x) nounwind {
  %1 = alloca i32, addrspace(5)
  store i32 7, ptr addrspace(5) %1
  %2 = load i32, ptr addrspace(5) %1
  %3 = call i1 @llvm.amdgcn.class.f32(float %x, i32 %2)
  %4 = xor i1 %3, -1
  ret i1 %4
}

; Negative test: should not transform for multiple uses of the
;   intrinsic returned value
; CHECK: @fold_negate_intrinsic_test_mask_neg_multiple_uses
; CHECK: %[[X1:.*]] = call i1 @llvm.amdgcn.class.f32(float %x, i32 7)
; CHECK: store i1 %[[X1]]
; CHECK: %[[X2:.*]] = xor i1 %[[X1]]
define i1 @fold_negate_intrinsic_test_mask_neg_multiple_uses(float %x) nounwind {
  %y = alloca i1, addrspace(5)
  %1 = call i1 @llvm.amdgcn.class.f32(float %x, i32 7)
  %2 = xor i1 %1, -1
  store i1 %1, ptr addrspace(5) %y
  %3 = xor i1 %1, -1
  ret i1 %2
}

; Negative test: should not transform for a xor with no operand equal to -1
; CHECK: @fold_negate_intrinsic_test_mask_neg_one
; CHECK: %[[X0:.*]] = call i1 @llvm.amdgcn.class.f32(float %x, i32 7)
; CHECK: xor i1 %[[X0]], false
define i1 @fold_negate_intrinsic_test_mask_neg_one(float %x) nounwind {
  %1 = call i1 @llvm.amdgcn.class.f32(float %x, i32 7)
  %2 = xor i1 %1, false
  ret i1 %2
}