]> granicus.if.org Git - llvm/commitdiff
[InstCombine] add test to show reassociation that creates a denormal constant; NFC
authorSanjay Patel <spatel@rotateright.com>
Fri, 5 Apr 2019 16:42:21 +0000 (16:42 +0000)
committerSanjay Patel <spatel@rotateright.com>
Fri, 5 Apr 2019 16:42:21 +0000 (16:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357776 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/InstCombine/fmul.ll

index 3d5821c62096570cafa5d85403e62deb5f377588..d8a970266ecccfebc3886034f50fa427c34f23ec 100644 (file)
@@ -460,6 +460,21 @@ define <4 x float> @fdiv_constant_denominator_fmul_vec_constexpr(<4 x float> %x)
   ret <4 x float> %t3
 }
 
+; This shows that at least part of instcombine does not check constant
+; values to see if it is creating denorms (0x3800000000000000 is a denorm
+; for 32-bit float), so protecting against denorms in other parts is
+; probably not doing the intended job.
+
+define float @fmul_constant_reassociation(float %x) {
+; CHECK-LABEL: @fmul_constant_reassociation(
+; CHECK-NEXT:    [[R:%.*]] = fmul reassoc nsz float [[X:%.*]], 0x3800000000000000
+; CHECK-NEXT:    ret float [[R]]
+;
+  %mul_flt_min = fmul reassoc nsz float %x, 0x3810000000000000
+  %r = fmul reassoc nsz float  %mul_flt_min, 0.5
+  ret float %r
+}
+
 ; Rule "X/C1 * C2 => X * (C2/C1) is not applicable if C2/C1 is abnormal
 ; 0x3810000000000000 == FLT_MIN