[llvm] [InstCombine] Transform high latency, dependent FSQRT/FDIV into FMUL (PR #87474)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 20 10:50:50 PDT 2024
================
@@ -0,0 +1,514 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
+; RUN: opt -S -passes='instcombine<no-verify-fixpoint>' < %s | FileCheck %s
+
+ at x = global double 0.000000e+00
+ at r1 = global double 0.000000e+00
+ at r2 = global double 0.000000e+00
+ at r3 = global double 0.000000e+00
+ at v = global [2 x double] zeroinitializer
+ at v1 = global [2 x double] zeroinitializer
+ at v2 = global [2 x double] zeroinitializer
+
+; div/mul/div1 in the same block.
+define void @bb_constraint_case1(double %a) {
+; CHECK-LABEL: define void @bb_constraint_case1(
+; CHECK-SAME: double [[A:%.*]]) {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[SQRT1:%.*]] = call reassoc double @llvm.sqrt.f64(double [[A]])
+; CHECK-NEXT: [[TMP0:%.*]] = fdiv reassoc double 1.000000e+00, [[A]]
+; CHECK-NEXT: [[DIV:%.*]] = fdiv reassoc ninf arcp double [[SQRT1]], [[A]]
+; CHECK-NEXT: store double [[DIV]], ptr @x, align 8
+; CHECK-NEXT: store double [[TMP0]], ptr @r1, align 8
+; CHECK-NEXT: store double [[SQRT1]], ptr @r2, align 8
+; CHECK-NEXT: ret void
+entry:
+ %sqrt = call reassoc nnan nsz ninf double @llvm.sqrt.f64(double %a)
+ %div = fdiv reassoc arcp ninf double 1.000000e+00, %sqrt
+ store double %div, ptr @x
+ %mul = fmul reassoc double %div, %div
+ store double %mul, ptr @r1
+ %div1 = fdiv reassoc double %a, %sqrt
+ store double %div1, ptr @r2
+ ret void
+}
+; div/mul in one block and div1 in other block with conditional guard.
----------------
arsenm wrote:
Blank line separating the function from the comment on the next function
https://github.com/llvm/llvm-project/pull/87474
More information about the llvm-commits
mailing list