[llvm] 3f4490d - [X86] Add one use check to '0-x == y --> x+y == 0' in EmitCmp.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 17 18:17:01 PST 2020


Author: Craig Topper
Date: 2020-02-17T18:16:42-08:00
New Revision: 3f4490d384c8b3c41bd9f8a4a17467769c7a55c0

URL: https://github.com/llvm/llvm-project/commit/3f4490d384c8b3c41bd9f8a4a17467769c7a55c0
DIFF: https://github.com/llvm/llvm-project/commit/3f4490d384c8b3c41bd9f8a4a17467769c7a55c0.diff

LOG: [X86] Add one use check to '0-x == y --> x+y == 0' in EmitCmp.

I failed to copy it when I moved this in
b62de210cf50ccb6822260e4075dd93333adb23e

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86ISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 96d41ed0e316..275a7bdc7c36 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -21212,7 +21212,7 @@ static SDValue EmitCmp(SDValue Op0, SDValue Op1, unsigned X86CC,
   // 0-x == y --> x+y == 0
   // 0-x != y --> x+y != 0
   if (Op0.getOpcode() == ISD::SUB && isNullConstant(Op0.getOperand(0)) &&
-      (X86CC == X86::COND_E || X86CC == X86::COND_NE)) {
+      Op0.hasOneUse() && (X86CC == X86::COND_E || X86CC == X86::COND_NE)) {
     SDVTList VTs = DAG.getVTList(CmpVT, MVT::i32);
     SDValue Add = DAG.getNode(X86ISD::ADD, dl, VTs, Op0.getOperand(1), Op1);
     return Add.getValue(1);
@@ -21221,7 +21221,7 @@ static SDValue EmitCmp(SDValue Op0, SDValue Op1, unsigned X86CC,
   // x == 0-y --> x+y == 0
   // x != 0-y --> x+y != 0
   if (Op1.getOpcode() == ISD::SUB && isNullConstant(Op1.getOperand(0)) &&
-      (X86CC == X86::COND_E || X86CC == X86::COND_NE)) {
+      Op1.hasOneUse() && (X86CC == X86::COND_E || X86CC == X86::COND_NE)) {
     SDVTList VTs = DAG.getVTList(CmpVT, MVT::i32);
     SDValue Add = DAG.getNode(X86ISD::ADD, dl, VTs, Op0, Op1.getOperand(1));
     return Add.getValue(1);


        


More information about the llvm-commits mailing list