forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SelectionDAG] Check any use of negation result before removal
2508ef0 fixed a bug about constant removal in negation. But after sanitizing check I found there's still some issue about it so it's reverted. Temporary nodes will be removed if useless in negation. Before the removal, they'd be checked if any other nodes used it. So the removal was moved after getNode. However in rare cases the node to be removed is the same as result of getNode. We missed that and will be fixed by this patch. Reviewed By: steven.zhang Differential Revision: https://reviews.llvm.org/D87614
- Loading branch information
Showing
2 changed files
with
43 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 correctly removed | ||
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 | ||
} |