[llvm] [ConstantFolding] Add edge cases for llvm.log{, 2, 10} (PR #173304)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 22 13:47:45 PST 2025


================
@@ -214,22 +214,96 @@ entry:
   ret float %1
 }
 
+define float @test_intrinsic_log() {
+; CHECK-LABEL: @test_intrinsic_log(
+  %v = alloca <3 x float>
+  %f = alloca float
+
 ; log(0.0) -> -inf
-; Check that log instrinsics fold through cases where libc will throw an exception
-define float @test_intrinsic_log_zero() {
-; CHECK-LABEL: @test_intrinsic_log_zero(
 ; CHECK-NOT: call
-; CHECK: ret float 0xFFF0000000000000
+; CHECK: store float 0xFFF0000000000000
   %1 = call float @llvm.log.f32(float 0.0)
+  store float %1, ptr %f
+
+; log(-x) -> NaN
+; CHECK-NOT: call
+; CHECK: store float 0x7FF8000000000000
+  %2 = call float @llvm.log.f32(float -20.0)
----------------
arsenm wrote:

Use named values in tests 

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


More information about the llvm-commits mailing list