[X86] Remove X86ISD::INC/DEC. Just select them from X86ISD::ADD/SUB at isel time
authorCraig Topper <craig.topper@intel.com>
Wed, 2 Jan 2019 19:01:05 +0000 (19:01 +0000)
committerCraig Topper <craig.topper@intel.com>
Wed, 2 Jan 2019 19:01:05 +0000 (19:01 +0000)
commit9d4860ec4e4091fd1ebe0332b955bfb91ab0b67a
tree518671cf914008f1180f1330aafa8790d7bf015d
parent10ac299a9d1b4b92f0a1579270a7f5c463d125e3
[X86] Remove X86ISD::INC/DEC. Just select them from X86ISD::ADD/SUB at isel time

INC/DEC are pretty much the same as ADD/SUB except that they don't update the C flag.

This patch removes the special nodes and just pattern matches from ADD/SUB during isel if the C flag isn't being used.

I had to avoid selecting DEC is the result isn't used. This will become a SUB immediate which will turned into a CMP later by optimizeCompareInstr. This lead to the one test change where we use a CMP instead of a DEC for an overflow intrinsic since we only checked the flag.

This also exposed a hole in our RMW flag matching use of hasNoCarryFlagUses. Our root node for the match is a store and there's no guarantee that all the flag users have been selected yet. So hasNoCarryFlagUses needs to check copyToReg and machine opcodes, but it also needs to check for the pre-match SETCC, SETCC_CARRY, BRCOND, and CMOV opcodes.

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

llvm-svn: 350245
llvm/lib/Target/X86/X86FastISel.cpp
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.h
llvm/lib/Target/X86/X86InstrArithmetic.td
llvm/lib/Target/X86/X86InstrCompiler.td
llvm/lib/Target/X86/X86InstrInfo.td
llvm/test/CodeGen/X86/sub-with-overflow.ll