[llvm] r329313 - [InstCombine] add tests for fsub --> fadd; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 5 09:51:09 PDT 2018
Author: spatel
Date: Thu Apr 5 09:51:09 2018
New Revision: 329313
URL: http://llvm.org/viewvc/llvm-project?rev=329313&view=rev
Log:
[InstCombine] add tests for fsub --> fadd; NFC
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=329313&r1=329312&r2=329313&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fsub.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/fsub.ll Thu Apr 5 09:51:09 2018
@@ -3,20 +3,20 @@
; PR4374
-define float @test1(float %a, float %b) nounwind {
+define float @test1(float %a, float %b) {
; CHECK-LABEL: @test1(
; CHECK-NEXT: [[T1:%.*]] = fsub float [[A:%.*]], [[B:%.*]]
; CHECK-NEXT: [[T2:%.*]] = fsub float -0.000000e+00, [[T1]]
; CHECK-NEXT: ret float [[T2]]
;
%t1 = fsub float %a, %b
- %t2 = fsub float -0.000000e+00, %t1
+ %t2 = fsub float -0.0, %t1
ret float %t2
}
; <rdar://problem/7530098>
-define double @test2(double %x, double %y) nounwind {
+define double @test2(double %x, double %y) {
; CHECK-LABEL: @test2(
; CHECK-NEXT: [[T1:%.*]] = fadd double [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[T2:%.*]] = fsub double [[X]], [[T1]]
@@ -27,3 +27,65 @@ define double @test2(double %x, double %
ret double %t2
}
+; X - C --> X + (-C)
+
+define float @constant_op1(float %x, float %y) {
+; CHECK-LABEL: @constant_op1(
+; CHECK-NEXT: [[R:%.*]] = fadd float [[X:%.*]], -4.200000e+01
+; CHECK-NEXT: ret float [[R]]
+;
+ %r = fsub float %x, 42.0
+ ret float %r
+}
+
+define <2 x float> @constant_op1_vec(<2 x float> %x, <2 x float> %y) {
+; CHECK-LABEL: @constant_op1_vec(
+; CHECK-NEXT: [[R:%.*]] = fadd <2 x float> [[X:%.*]], <float -4.200000e+01, float 4.200000e+01>
+; CHECK-NEXT: ret <2 x float> [[R]]
+;
+ %r = fsub <2 x float> %x, <float 42.0, float -42.0>
+ ret <2 x float> %r
+}
+
+define <2 x float> @constant_op1_vec_undef(<2 x float> %x, <2 x float> %y) {
+; CHECK-LABEL: @constant_op1_vec_undef(
+; CHECK-NEXT: [[R:%.*]] = fsub <2 x float> [[X:%.*]], <float undef, float -4.200000e+01>
+; CHECK-NEXT: ret <2 x float> [[R]]
+;
+ %r = fsub <2 x float> %x, <float undef, float -42.0>
+ ret <2 x float> %r
+}
+
+; X - (-Y) --> X + Y
+
+define float @neg_op1(float %x, float %y) {
+; CHECK-LABEL: @neg_op1(
+; CHECK-NEXT: [[R:%.*]] = fadd float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: ret float [[R]]
+;
+ %negy = fsub float -0.0, %y
+ %r = fsub float %x, %negy
+ ret float %r
+}
+
+define <2 x float> @neg_op1_vec(<2 x float> %x, <2 x float> %y) {
+; CHECK-LABEL: @neg_op1_vec(
+; CHECK-NEXT: [[R:%.*]] = fadd <2 x float> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: ret <2 x float> [[R]]
+;
+ %negy = fsub <2 x float> <float -0.0, float -0.0>, %y
+ %r = fsub <2 x float> %x, %negy
+ ret <2 x float> %r
+}
+
+define <2 x float> @neg_op1_vec_undef(<2 x float> %x, <2 x float> %y) {
+; CHECK-LABEL: @neg_op1_vec_undef(
+; CHECK-NEXT: [[NEGY:%.*]] = fsub <2 x float> <float -0.000000e+00, float undef>, [[Y:%.*]]
+; CHECK-NEXT: [[R:%.*]] = fsub <2 x float> [[X:%.*]], [[NEGY]]
+; CHECK-NEXT: ret <2 x float> [[R]]
+;
+ %negy = fsub <2 x float> <float -0.0, float undef>, %y
+ %r = fsub <2 x float> %x, %negy
+ ret <2 x float> %r
+}
+
More information about the llvm-commits
mailing list