summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/IR/Constants.cpp7
-rw-r--r--llvm/test/Transforms/InstCombine/shuffle_select.ll6
-rw-r--r--llvm/test/Transforms/Reassociate/binop-identity.ll7
-rw-r--r--llvm/test/Transforms/Reassociate/reassoc-intermediate-fnegs.ll10
4 files changed, 15 insertions, 15 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index 9b8670c7f3f..3ea7598c11e 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -2281,7 +2281,12 @@ Constant *ConstantExpr::getBinOpIdentity(unsigned Opcode, Type *Ty) {
case Instruction::And:
return Constant::getAllOnesValue(Ty);
- // FIXME: FAdd / FMul?
+ // TODO: If the fadd has 'nsz', should we return +0.0?
+ case Instruction::FAdd:
+ return ConstantFP::getNegativeZero(Ty);
+
+ case Instruction::FMul:
+ return ConstantFP::get(Ty, 1.0);
}
}
diff --git a/llvm/test/Transforms/InstCombine/shuffle_select.ll b/llvm/test/Transforms/InstCombine/shuffle_select.ll
index 1b568203372..8f3d13840c8 100644
--- a/llvm/test/Transforms/InstCombine/shuffle_select.ll
+++ b/llvm/test/Transforms/InstCombine/shuffle_select.ll
@@ -163,8 +163,7 @@ define <4 x i32> @srem(<4 x i32> %v) {
define <4 x float> @fadd(<4 x float> %v) {
; CHECK-LABEL: @fadd(
-; CHECK-NEXT: [[B:%.*]] = fadd <4 x float> [[V:%.*]], <float 4.100000e+01, float 4.200000e+01, float 4.300000e+01, float 4.400000e+01>
-; CHECK-NEXT: [[S:%.*]] = shufflevector <4 x float> [[B]], <4 x float> [[V]], <4 x i32> <i32 0, i32 1, i32 6, i32 7>
+; CHECK-NEXT: [[S:%.*]] = fadd <4 x float> [[V:%.*]], <float 4.100000e+01, float 4.200000e+01, float -0.000000e+00, float -0.000000e+00>
; CHECK-NEXT: ret <4 x float> [[S]]
;
%b = fadd <4 x float> %v, <float 41.0, float 42.0, float 43.0, float 44.0>
@@ -187,8 +186,7 @@ define <4 x double> @fsub(<4 x double> %v) {
define <4 x float> @fmul(<4 x float> %v) {
; CHECK-LABEL: @fmul(
-; CHECK-NEXT: [[B:%.*]] = fmul nnan ninf <4 x float> [[V:%.*]], <float 4.100000e+01, float 4.200000e+01, float 4.300000e+01, float 4.400000e+01>
-; CHECK-NEXT: [[S:%.*]] = shufflevector <4 x float> [[B]], <4 x float> [[V]], <4 x i32> <i32 0, i32 5, i32 6, i32 7>
+; CHECK-NEXT: [[S:%.*]] = fmul nnan ninf <4 x float> [[V:%.*]], <float 4.100000e+01, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>
; CHECK-NEXT: ret <4 x float> [[S]]
;
%b = fmul nnan ninf <4 x float> %v, <float 41.0, float 42.0, float 43.0, float 44.0>
diff --git a/llvm/test/Transforms/Reassociate/binop-identity.ll b/llvm/test/Transforms/Reassociate/binop-identity.ll
index 12a6c7867ec..13333fad599 100644
--- a/llvm/test/Transforms/Reassociate/binop-identity.ll
+++ b/llvm/test/Transforms/Reassociate/binop-identity.ll
@@ -48,7 +48,7 @@ define i8 @xor_0(i8 %x) {
ret i8 %a2
}
-; FIXME
+; FIXME - the binop identity constant for fadd is -0.0, so this didn't fold.
define float @fadd_0(float %x) {
; CHECK-LABEL: @fadd_0(
@@ -60,12 +60,9 @@ define float @fadd_0(float %x) {
ret float %a2
}
-; FIXME
-
define float @fmul_1(float %x) {
; CHECK-LABEL: @fmul_1(
-; CHECK-NEXT: [[A2:%.*]] = fmul fast float [[X:%.*]], 1.000000e+00
-; CHECK-NEXT: ret float [[A2]]
+; CHECK-NEXT: ret float [[X:%.*]]
;
%a1 = fmul fast float %x, 4.0
%a2 = fmul fast float %a1, 0.25
diff --git a/llvm/test/Transforms/Reassociate/reassoc-intermediate-fnegs.ll b/llvm/test/Transforms/Reassociate/reassoc-intermediate-fnegs.ll
index 84287c5c178..3bd8396638a 100644
--- a/llvm/test/Transforms/Reassociate/reassoc-intermediate-fnegs.ll
+++ b/llvm/test/Transforms/Reassociate/reassoc-intermediate-fnegs.ll
@@ -1,11 +1,12 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -reassociate -S | FileCheck %s
; Input is A op (B op C)
define half @faddsubAssoc1(half %a, half %b) {
; CHECK-LABEL: @faddsubAssoc1(
-; CHECK-NEXT: [[T2_NEG:%.*]] = fmul fast half %a, 0xH4500
-; CHECK-NEXT: [[REASS_MUL:%.*]] = fmul fast half %b, 0xH4500
+; CHECK-NEXT: [[T2_NEG:%.*]] = fmul fast half [[A:%.*]], 0xH4500
+; CHECK-NEXT: [[REASS_MUL:%.*]] = fmul fast half [[B:%.*]], 0xH4500
; CHECK-NEXT: [[T51:%.*]] = fsub fast half [[REASS_MUL]], [[T2_NEG]]
; CHECK-NEXT: [[T5:%.*]] = fadd fast half [[REASS_MUL]], [[T2_NEG]]
; CHECK-NEXT: ret half [[T51]]
@@ -22,9 +23,8 @@ define half @faddsubAssoc1(half %a, half %b) {
define half @faddsubAssoc2(half %a, half %b) {
; CHECK-LABEL: @faddsubAssoc2(
-; CHECK-NEXT: [[T2:%.*]] = fmul fast half %a, 0xH4500
-; CHECK-NEXT: [[REASS_MUL:%.*]] = fmul fast half %b, 0xH3C00
-; CHECK-NEXT: [[T5:%.*]] = fadd fast half [[REASS_MUL]], [[T2]]
+; CHECK-NEXT: [[T2:%.*]] = fmul fast half [[A:%.*]], 0xH4500
+; CHECK-NEXT: [[T5:%.*]] = fadd fast half [[B:%.*]], [[T2]]
; CHECK-NEXT: ret half [[T5]]
;
%t1 = fmul fast half %b, 0xH4200 ; 3*b
OpenPOWER on IntegriCloud