]> granicus.if.org Git - llvm/commitdiff
[X86][btver2] PR31902: Fix a crash in combineOrCmpEqZeroToCtlzSrl under fast math.
authorPierre Gousseau <pierregousseau14@gmail.com>
Thu, 9 Feb 2017 14:43:58 +0000 (14:43 +0000)
committerPierre Gousseau <pierregousseau14@gmail.com>
Thu, 9 Feb 2017 14:43:58 +0000 (14:43 +0000)
In combineOrCmpEqZeroToCtlzSrl, replace "getConstantOperand == 0" by "isNullConstant" to account for floating point constants.

Differential Revision: https://reviews.llvm.org/D29756

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294588 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/lzcnt-zext-cmp.ll

index 6f9f6771e33a4d54b0a6a8f5c4b2f8ce909bcf9c..1ca1402a1a9e656ec79ec066fa571797137fd480 100644 (file)
@@ -31166,7 +31166,7 @@ static SDValue combineOrCmpEqZeroToCtlzSrl(SDNode *N, SelectionDAG &DAG,
     return N->getOpcode() == X86ISD::SETCC && N->hasOneUse() &&
            X86::CondCode(N->getConstantOperandVal(0)) == X86::COND_E &&
            N->getOperand(1).getOpcode() == X86ISD::CMP &&
-           N->getOperand(1).getConstantOperandVal(1) == 0 &&
+           isNullConstant(N->getOperand(1).getOperand(1)) &&
            N->getOperand(1).getValueType().bitsGE(MVT::i32);
   };
 
index c69dbf573f46d9f4e72f6e8dfcc3ec7f733bd2ce..6465e370c9743ba09b251d0e7b33cfbc28dca430 100644 (file)
@@ -341,3 +341,34 @@ entry:
   %lor.ext = zext i1 %0 to i32
   ret i32 %lor.ext
 }
+
+; PR31902 Fix a crash in combineOrCmpEqZeroToCtlzSrl under fast math.
+define i32 @test_zext_cmp11(double %a, double %b) "no-nans-fp-math"="true" {
+; CHECK-LABEL: test_zext_cmp11:
+; CHECK:       # BB#0: # %entry
+; CHECK-NEXT:    vxorps %xmm2, %xmm2, %xmm2
+; CHECK-NEXT:    vucomisd %xmm2, %xmm0
+; CHECK-NEXT:    sete %al
+; CHECK-NEXT:    vucomisd %xmm2, %xmm1
+; CHECK-NEXT:    sete %cl
+; CHECK-NEXT:    orb %al, %cl
+; CHECK-NEXT:    movzbl %cl, %eax
+; CHECK-NEXT:    retq
+;
+; NOFASTLZCNT-LABEL: test_zext_cmp11:
+; NOFASTLZCNT:       # BB#0: # %entry
+; NOFASTLZCNT-NEXT:    vxorps %xmm2, %xmm2, %xmm2
+; NOFASTLZCNT-NEXT:    vucomisd %xmm2, %xmm0
+; NOFASTLZCNT-NEXT:    sete %al
+; NOFASTLZCNT-NEXT:    vucomisd %xmm2, %xmm1
+; NOFASTLZCNT-NEXT:    sete %cl
+; NOFASTLZCNT-NEXT:    orb %al, %cl
+; NOFASTLZCNT-NEXT:    movzbl %cl, %eax
+; NOFASTLZCNT-NEXT:    retq
+entry:
+  %cmp = fcmp fast oeq double %a, 0.000000e+00
+  %cmp1 = fcmp fast oeq double %b, 0.000000e+00
+  %0 = or i1 %cmp, %cmp1
+  %conv = zext i1 %0 to i32
+  ret i32 %conv
+}