[PATCH] D87614: [SelectionDAG] Remove unused FP constant in getNegatedExpression
Qiu Chaofan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 15 03:04:23 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2508ef014e8b: [SelectionDAG] Remove unused FP constant in getNegatedExpression (authored by qiucf).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87614/new/
https://reviews.llvm.org/D87614
Files:
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/X86/pr47517.ll
Index: llvm/test/CodeGen/X86/pr47517.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/pr47517.ll
@@ -0,0 +1,28 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple x86_64 < %s | FileCheck %s
+
+; To ensure unused floating point constant is removed in negation
+define float @test(float %src, float* %p) {
+; CHECK-LABEL: test:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: movq $0, (%rdi)
+; CHECK-NEXT: xorps %xmm0, %xmm0
+; CHECK-NEXT: retq
+entry:
+ %a0 = getelementptr inbounds float, float* %p, i32 0
+ %a1 = getelementptr inbounds float, float* %p, i32 1
+ store float 0.000000e+00, float* %a0
+ store float 0.000000e+00, float* %a1
+ %zero = load float, float* %a0
+ %fmul1 = fmul fast float %zero, %src
+ %fadd1 = fadd fast float %fmul1, %zero
+ %fmul2 = fmul fast float %fadd1, 2.000000e+00
+ %fmul3 = fmul fast float %fmul2, %fmul2
+ %fmul4 = fmul fast float %fmul2, 2.000000e+00
+ %fadd2 = fadd fast float %fmul4, -3.000000e+00
+ %fmul5 = fmul fast float %fadd2, %fmul2
+ %fadd3 = fadd fast float %fmul2, %src
+ %fadd4 = fadd fast float %fadd3, %fmul5
+ %fmul6 = fmul fast float %fmul3, %fadd4
+ ret float %fmul6
+}
Index: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -5773,8 +5773,10 @@
// If we already have the use of the negated floating constant, it is free
// to negate it even it has multiple uses.
- if (!Op.hasOneUse() && CFP.use_empty())
+ if (!Op.hasOneUse() && CFP.use_empty()) {
+ RemoveDeadNode(CFP);
break;
+ }
Cost = NegatibleCost::Neutral;
return CFP;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87614.291841.patch
Type: text/x-patch
Size: 1849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200915/e1f693ae/attachment.bin>
More information about the llvm-commits
mailing list