Skip to content

Commit c3604ba

Browse files
committed
AMDGPU: Add is_fpclass to isBoolSGPR
1 parent 2b9ded6 commit c3604ba

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11908,6 +11908,7 @@ bool llvm::isBoolSGPR(SDValue V) {
1190811908
default:
1190911909
break;
1191011910
case ISD::SETCC:
11911+
case ISD::IS_FPCLASS:
1191111912
case AMDGPUISD::FP_CLASS:
1191211913
return true;
1191311914
case ISD::AND:

llvm/test/CodeGen/AMDGPU/combine-and-sext-bool.ll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,31 @@ bb:
2020
ret void
2121
}
2222

23+
; GCN-LABEL: {{^}}and_sext_bool_fcmp:
24+
; GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
25+
; GCN-NEXT: v_cmp_eq_f32_e32 vcc, 0, v0
26+
; GCN-NEXT: v_cndmask_b32_e32 v0, 0, v1, vcc
27+
; GCN-NEXT: s_setpc_b64
28+
define i32 @and_sext_bool_fcmp(float %x, i32 %y) {
29+
%cmp = fcmp oeq float %x, 0.0
30+
%sext = sext i1 %cmp to i32
31+
%and = and i32 %sext, %y
32+
ret i32 %and
33+
}
34+
35+
; GCN-LABEL: {{^}}and_sext_bool_fpclass:
36+
; GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
37+
; GCN-NEXT: v_mov_b32_e32 [[K:v[0-9]+]], 0x7b
38+
; GCN-NEXT: v_cmp_class_f32_e32 vcc, v0, [[K]]
39+
; GCN-NEXT: v_cndmask_b32_e32 v0, 0, v1, vcc
40+
; GCN-NEXT: s_setpc_b64
41+
define i32 @and_sext_bool_fpclass(float %x, i32 %y) {
42+
%class = call i1 @llvm.is.fpclass(float %x, i32 123)
43+
%sext = sext i1 %class to i32
44+
%and = and i32 %sext, %y
45+
ret i32 %and
46+
}
47+
2348
declare i32 @llvm.amdgcn.workitem.id.x() #0
2449

2550
declare i32 @llvm.amdgcn.workitem.id.y() #0

0 commit comments

Comments
 (0)