[llvm] r329322 - [InstCombine] add test for fneg+fsub with nsz; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 5 10:40:51 PDT 2018
Author: spatel
Date: Thu Apr 5 10:40:51 2018
New Revision: 329322
URL: http://llvm.org/viewvc/llvm-project?rev=329322&view=rev
Log:
[InstCombine] add test for fneg+fsub with nsz; NFC
There used to be a fold that would handle this case more generally,
but it was removed at rL73243 to fix PR4374:
https://bugs.llvm.org/show_bug.cgi?id=4374
Modified:
llvm/trunk/test/Transforms/InstCombine/fsub.ll
Modified: llvm/trunk/test/Transforms/InstCombine/fsub.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fsub.ll?rev=329322&r1=329321&r2=329322&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fsub.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/fsub.ll Thu Apr 5 10:40:51 2018
@@ -3,17 +3,31 @@
; PR4374
-define float @test1(float %a, float %b) {
+define float @test1(float %x, float %y) {
; CHECK-LABEL: @test1(
-; CHECK-NEXT: [[T1:%.*]] = fsub float [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[T1:%.*]] = fsub float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[T2:%.*]] = fsub float -0.000000e+00, [[T1]]
; CHECK-NEXT: ret float [[T2]]
;
- %t1 = fsub float %a, %b
+ %t1 = fsub float %x, %y
%t2 = fsub float -0.0, %t1
ret float %t2
}
+; FIXME: Can't do anything with the test above because -0.0 - 0.0 = -0.0, but if we have nsz:
+; -(X - Y) --> Y - X
+
+define float @neg_sub(float %x, float %y) {
+; CHECK-LABEL: @neg_sub(
+; CHECK-NEXT: [[T1:%.*]] = fsub float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[T2:%.*]] = fsub nsz float -0.000000e+00, [[T1]]
+; CHECK-NEXT: ret float [[T2]]
+;
+ %t1 = fsub float %x, %y
+ %t2 = fsub nsz float -0.0, %t1
+ ret float %t2
+}
+
; <rdar://problem/7530098>
define double @test2(double %x, double %y) {
More information about the llvm-commits
mailing list