[llvm] [llvm] Don't combine repeated subnormal divisors (PR #149333)

Asher Mancinelli via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 17 12:17:26 PDT 2025


================
@@ -0,0 +1,22 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=x86_64 -verify-machineinstrs < %s | FileCheck %s
+
+; Negative test: repeated FP divisor transform should bail out when the rewrite
+; would introduce infinities because of subnormal constant divisors.
+define void @two_denorm_fdivs(float %a0, float %a1, float %a2, ptr %res) {
+; CHECK-LABEL: two_denorm_fdivs:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    movss {{.*#+}} xmm0 = [1.95915678E-39,0.0E+0,0.0E+0,0.0E+0]
+; CHECK-NEXT:    divss %xmm0, %xmm1
+; CHECK-NEXT:    movss %xmm1, (%rdi)
+; CHECK-NEXT:    divss %xmm0, %xmm2
+; CHECK-NEXT:    movss %xmm2, 4(%rdi)
+; CHECK-NEXT:    retq
+entry:
+  %div0 = fdiv ninf float %a1, 0x37E5555500000000
----------------
ashermancinelli wrote:

I think you're right, I reduced this a bit too far and it doesn't repro the bug. I'll need to update this if folks are amenable to this change.

https://github.com/llvm/llvm-project/pull/149333


More information about the llvm-commits mailing list