Skip to content

Commit 3fc1e66

Browse files
igorban-inteligcbot
authored andcommitted
Do not apply GenXPatternMatch on scalar instructions
.
1 parent 482b697 commit 3fc1e66

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXPatternMatch.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,8 +1257,10 @@ bool GenXPatternMatch::matchFloatAbs(BinaryOperator *I) {
12571257
return false;
12581258

12591259
uint64_t SplatV = 0;
1260-
1261-
if (auto *C = dyn_cast<ConstantData>(I->getOperand(1))) {
1260+
auto *Op = I->getOperand(1);
1261+
if (auto *C = dyn_cast<ConstantInt>(Op)) {
1262+
SplatV = C->getZExtValue();
1263+
} else if (auto *C = dyn_cast<ConstantData>(Op)) {
12621264
auto *Splat = dyn_cast_or_null<ConstantInt>(C->getSplatValue());
12631265
if (!Splat)
12641266
return false;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
;=========================== begin_copyright_notice ============================
2+
;
3+
; Copyright (C) 2021-2024 Intel Corporation
4+
;
5+
; SPDX-License-Identifier: MIT
6+
;
7+
;============================ end_copyright_notice =============================
8+
9+
; RUN: %opt %use_old_pass_manager% -GenXPatternMatch --enable-bfn=true \
10+
; RUN: -march=genx64 -mcpu=XeHPC -mtriple=spir64-unknown-unknown -S < %s | FileCheck %s
11+
12+
; Test verifies that there will be no asserts here
13+
; CHECK-LABEL: internal spir_func float @and_absf
14+
define internal spir_func float @and_absf(float %0) {
15+
; CHECK: call float @llvm.genx.absf.f32
16+
%.cast = bitcast float 1.000000e+00 to i32
17+
%2 = and i32 %.cast, 2147483647
18+
%.cast22 = bitcast i32 %2 to float
19+
ret float %.cast22
20+
}

0 commit comments

Comments
 (0)