summaryrefslogtreecommitdiff
path: root/llvm/lib/Target/X86/X86InstrInfo.h
diff options
context:
space:
mode:
authorMatthias Braun <matthiasb@fb.com>2021-09-27 17:57:22 -0700
committerMatthias Braun <matze@braunis.de>2022-01-11 09:07:29 -0800
commitad25f8a556d239d8b7d17383cf1a0771359521fd (patch)
tree93eb034f7cbf67f9f4a294b10f8955c077c2eff7 /llvm/lib/Target/X86/X86InstrInfo.h
parentbe1cc64cc13cb24bcd9ed097925a140d74beaa45 (diff)
downloadllvm-optimize_compinstr_fix.tar.gz
X86InstrInfo: Support immediates that are +1/-1 different in optimizeCompareInstroptimize_compinstr_fix
This is a re-commit of e2c7ee0743592e39274e28dbe0d0c213ba342317 which was reverted in a2a58d91e82db38fbdf88cc317dcb3753d79d492 and ea81cea8163a1a0e54df42103ee1c657bbf03791. This includes a fix to consistently check for EFLAGS being live-out. See phabricator review. Original Summary: This extends `optimizeCompareInstr` to re-use previous comparison results if the previous comparison was with an immediate that was 1 bigger or smaller. Example: CMP x, 13 ... CMP x, 12 ; can be removed if we change the SETg SETg ... ; x > 12 changed to `SETge` (x >= 13) removing CMP Motivation: This often happens because SelectionDAG canonicalization tends to add/subtract 1 often when optimizing for fallthrough blocks. Example for `x > C` the fallthrough optimization switches true/false blocks with `!(x > C)` --> `x <= C` and canonicalization turns this into `x < C + 1`. Differential Revision: https://reviews.llvm.org/D110867
Diffstat (limited to 'llvm/lib/Target/X86/X86InstrInfo.h')
-rw-r--r--llvm/lib/Target/X86/X86InstrInfo.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Target/X86/X86InstrInfo.h b/llvm/lib/Target/X86/X86InstrInfo.h
index 537ada6222bf..33ce55bbdb2b 100644
--- a/llvm/lib/Target/X86/X86InstrInfo.h
+++ b/llvm/lib/Target/X86/X86InstrInfo.h
@@ -643,7 +643,8 @@ private:
/// CMP %1, %2 and %3 = SUB %2, %1 ; IsSwapped=true
bool isRedundantFlagInstr(const MachineInstr &FlagI, Register SrcReg,
Register SrcReg2, int64_t ImmMask, int64_t ImmValue,
- const MachineInstr &OI, bool *IsSwapped) const;
+ const MachineInstr &OI, bool *IsSwapped,
+ int64_t *ImmDelta) const;
};
} // namespace llvm