[llvm] [DAG] visitIS_FPCLASS - fold to constant when result is fully determined by KnownFPClass (PR #193737)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 23 06:22:59 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-risc-v
Author: Xinlong Chen (Xinlong-Chen)
<details>
<summary>Changes</summary>
This PR teaches `DAGCombiner::visitIS_FPCLASS` to fold directly to constant `false`/`true` based on the source's `KnownFPClass`, instead of only narrowing the test mask.
Prep work to help with https://github.com/llvm/llvm-project/pull/193672
---
Full diff: https://github.com/llvm/llvm-project/pull/193737.diff
1 Files Affected:
- (modified) llvm/test/CodeGen/RISCV/combine-is_fpclass.ll (+13)
``````````diff
diff --git a/llvm/test/CodeGen/RISCV/combine-is_fpclass.ll b/llvm/test/CodeGen/RISCV/combine-is_fpclass.ll
index 71621b8837d6b..d325f9563f6c3 100644
--- a/llvm/test/CodeGen/RISCV/combine-is_fpclass.ll
+++ b/llvm/test/CodeGen/RISCV/combine-is_fpclass.ll
@@ -186,6 +186,19 @@ define i1 @extract_scalable_fabs_isneg(<vscale x 4 x float> %a0) nounwind {
ret i1 %res
}
+define i1 @fabs_is_nonneg_or_nan(float %x) nounwind {
+; CHECK-LABEL: fabs_is_nonneg_or_nan:
+; CHECK: # %bb.0:
+; CHECK-NEXT: fabs.s fa5, fa0
+; CHECK-NEXT: fclass.s a0, fa5
+; CHECK-NEXT: andi a0, a0, 1008
+; CHECK-NEXT: snez a0, a0
+; CHECK-NEXT: ret
+ %a = call float @llvm.fabs.f32(float %x)
+ %res = call i1 @llvm.is.fpclass.f32(float %a, i32 963) ; 0x3C3 = any positive | nan
+ ret i1 %res
+}
+
define <vscale x 4 x i1> @splat_constant_is_pos_normal() {
; CHECK-LABEL: splat_constant_is_pos_normal:
; CHECK: # %bb.0:
``````````
</details>
https://github.com/llvm/llvm-project/pull/193737
More information about the llvm-commits
mailing list