File: bfi.ll

package info (click to toggle)
intel-graphics-compiler2 2.16.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 106,644 kB
  • sloc: cpp: 805,640; lisp: 287,672; ansic: 16,414; python: 3,952; yacc: 2,588; lex: 1,666; pascal: 313; sh: 186; makefile: 35
file content (69 lines) | stat: -rw-r--r-- 2,532 bytes parent folder | download
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
67
68
69
;=========================== begin_copyright_notice ============================
;
; Copyright (C) 2024 Intel Corporation
;
; SPDX-License-Identifier: MIT
;
;============================ end_copyright_notice =============================
;
; RUN: igc_opt -igc-custom-safe-opt -dce -S < %s | FileCheck %s
; ------------------------------------------------
; CustomSafeOptPass: GenISA.bfi
; ------------------------------------------------

; arg0 - width
; arg1 - offset
; arg2 - the number the bits are taken from.
; arg3 - the number with bits to be replaced.
declare i32 @llvm.genx.GenISA.bfi(i32, i32, i32, i32)

; Check that if width is 0, then the resulting value is arg2
define i32 @test_bfi_w0(i32 %offset, i32 %src, i32 %dst) {
; CHECK-LABEL: define i32 @test_bfi_w0(
; CHECK-SAME: i32 [[OFFSET:%.*]], i32 [[SRC:%.*]], i32 [[DST:%.*]]) {
; CHECK:    ret i32 [[DST]]
;
  %1 = call i32 @llvm.genx.GenISA.bfi(i32 0, i32 %offset, i32 %src, i32 %dst)
  ret i32 %1
}

; Check that if arg3 is constant then it's more profitable just to do implied calculations
define i32 @test_bfi_const_s3(i32 %src) {
; CHECK-LABEL: define i32 @test_bfi_const_s3(
; CHECK-SAME: i32 [[SRC:%.*]]) {
; CHECK:    [[TMP1:%.*]] = shl i32 [[SRC]], 16
; CHECK:    [[TMP2:%.*]] = and i32 [[TMP1]], -65536
; COM: 48059 = 0xBBBB
; CHECK:    [[TMP3:%.*]] = or i32 [[TMP2]], 48059
; CHECK:    ret i32 [[TMP3]]
;
  %1 = call i32 @llvm.genx.GenISA.bfi(i32 16, i32 16, i32 %src, i32 2863315899) ; 0xaaaabbbb
  ret i32 %1
}

; Check that if arg3 is a constant then it's more profitable just to do implied calculations
; arg3 is zero, no need for masking (and + or) of arg3
define i32 @test_bfi_const_s3_zero(i32 %src) {
; CHECK-LABEL: define i32 @test_bfi_const_s3_zero(
; CHECK-SAME: i32 [[SRC:%.*]]) {
; CHECK:    [[TMP1:%.*]] = shl i32 [[SRC]], 8
; CHECK:    [[TMP2:%.*]] = and i32 [[TMP1]], 16776960
; CHECK:    ret i32 [[TMP2]]
;
  %1 = call i32 @llvm.genx.GenISA.bfi(i32 16, i32 8, i32 %src, i32 0)
  ret i32 %1
}

; Check that if offset is zero then it's more profitable just to do implied calculations
; Offset is zero, no need for initial shl
define i32 @test_bfi_off0(i32 %src, i32 %dst) {
; CHECK-LABEL: define i32 @test_bfi_off0(
; CHECK-SAME: i32 [[SRC:%.*]], i32 [[DST:%.*]]) {
; CHECK:    [[TMP1:%.*]] = and i32 [[SRC]], 65535
; CHECK:    [[TMP2:%.*]] = and i32 [[DST]], -65536
; CHECK:    [[TMP3:%.*]] = or i32 [[TMP1]], [[TMP2]]
; CHECK:    ret i32 [[TMP3]]
;
  %1 = call i32 @llvm.genx.GenISA.bfi(i32 16, i32 0, i32 %src, i32 %dst)
  ret i32 %1
}