[llvm] r325642 - [PatternMatch] allow vector matches with m_FNeg

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 20 15:29:05 PST 2018


Author: spatel
Date: Tue Feb 20 15:29:05 2018
New Revision: 325642

URL: http://llvm.org/viewvc/llvm-project?rev=325642&view=rev
Log:
[PatternMatch] allow vector matches with m_FNeg

Modified:
    llvm/trunk/include/llvm/IR/PatternMatch.h
    llvm/trunk/test/Transforms/InstCombine/cos-intrinsic.ll
    llvm/trunk/test/Transforms/InstCombine/fdiv.ll

Modified: llvm/trunk/include/llvm/IR/PatternMatch.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/PatternMatch.h?rev=325642&r1=325641&r2=325642&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/PatternMatch.h (original)
+++ llvm/trunk/include/llvm/IR/PatternMatch.h Tue Feb 20 15:29:05 2018
@@ -1101,7 +1101,7 @@ template <typename LHS_t> struct fneg_ma
 
 private:
   bool matchIfFNeg(Value *LHS, Value *RHS) {
-    if (const auto *C = dyn_cast<ConstantFP>(LHS))
+    if (const auto *C = dyn_cast<Constant>(LHS))
       return C->isNegativeZeroValue() && L.match(RHS);
     return false;
   }

Modified: llvm/trunk/test/Transforms/InstCombine/cos-intrinsic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cos-intrinsic.ll?rev=325642&r1=325641&r2=325642&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/cos-intrinsic.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/cos-intrinsic.ll Tue Feb 20 15:29:05 2018
@@ -38,12 +38,9 @@ define float @fneg_f32(float %x) {
   ret float %cos
 }
 
-; FIXME: m_FNeg() doesn't handle vectors
-
 define <2 x float> @fneg_v2f32(<2 x float> %x) {
 ; CHECK-LABEL: @fneg_v2f32(
-; CHECK-NEXT:    [[X_FNEG:%.*]] = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, [[X:%.*]]
-; CHECK-NEXT:    [[COS:%.*]] = call <2 x float> @llvm.cos.v2f32(<2 x float> [[X_FNEG]])
+; CHECK-NEXT:    [[COS:%.*]] = call <2 x float> @llvm.cos.v2f32(<2 x float> [[X:%.*]])
 ; CHECK-NEXT:    ret <2 x float> [[COS]]
 ;
   %x.fneg = fsub <2 x float> <float -0.0, float -0.0>, %x
@@ -74,9 +71,7 @@ define float @fabs_fneg_f32(float %x) {
 
 define <2 x float> @fabs_fneg_v2f32(<2 x float> %x) {
 ; CHECK-LABEL: @fabs_fneg_v2f32(
-; CHECK-NEXT:    [[X_FABS:%.*]] = call <2 x float> @llvm.fabs.v2f32(<2 x float> [[X:%.*]])
-; CHECK-NEXT:    [[X_FABS_FNEG:%.*]] = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, [[X_FABS]]
-; CHECK-NEXT:    [[COS:%.*]] = call <2 x float> @llvm.cos.v2f32(<2 x float> [[X_FABS_FNEG]])
+; CHECK-NEXT:    [[COS:%.*]] = call <2 x float> @llvm.cos.v2f32(<2 x float> [[X:%.*]])
 ; CHECK-NEXT:    ret <2 x float> [[COS]]
 ;
   %x.fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %x)

Modified: llvm/trunk/test/Transforms/InstCombine/fdiv.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fdiv.ll?rev=325642&r1=325641&r2=325642&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fdiv.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/fdiv.ll Tue Feb 20 15:29:05 2018
@@ -204,9 +204,7 @@ define float @fneg_fneg_fast(float %x, f
 
 define <2 x float> @fneg_fneg_vec(<2 x float> %x, <2 x float> %y) {
 ; CHECK-LABEL: @fneg_fneg_vec(
-; CHECK-NEXT:    [[XNEG:%.*]] = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, [[X:%.*]]
-; CHECK-NEXT:    [[YNEG:%.*]] = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, [[Y:%.*]]
-; CHECK-NEXT:    [[DIV:%.*]] = fdiv <2 x float> [[XNEG]], [[YNEG]]
+; CHECK-NEXT:    [[DIV:%.*]] = fdiv <2 x float> [[X:%.*]], [[Y:%.*]]
 ; CHECK-NEXT:    ret <2 x float> [[DIV]]
 ;
   %xneg = fsub <2 x float> <float -0.0, float -0.0>, %x




More information about the llvm-commits mailing list