From d6a2f460c7d221f9598bb011de592dda4caacdd1 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Sun, 30 Aug 2020 11:36:41 -0400 Subject: [PATCH] [FastISel] update to use intrinsic's isCommutative(); NFC This requires adding a missing 'const' to the definition because the callers are using const args, but there should be no change in behavior. The intrinsic method was added with D86798 / rG096527214033 --- include/llvm/CodeGen/FastISel.h | 12 ------------ include/llvm/IR/IntrinsicInst.h | 2 +- lib/Target/AArch64/AArch64FastISel.cpp | 6 ++---- lib/Target/X86/X86FastISel.cpp | 3 +-- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/include/llvm/CodeGen/FastISel.h b/include/llvm/CodeGen/FastISel.h index 7662179db44..5c1ebc7af17 100644 --- a/include/llvm/CodeGen/FastISel.h +++ b/include/llvm/CodeGen/FastISel.h @@ -510,18 +510,6 @@ protected: unsigned NumArgs); bool lowerCallTo(CallLoweringInfo &CLI); - bool isCommutativeIntrinsic(IntrinsicInst const *II) { - switch (II->getIntrinsicID()) { - case Intrinsic::sadd_with_overflow: - case Intrinsic::uadd_with_overflow: - case Intrinsic::smul_with_overflow: - case Intrinsic::umul_with_overflow: - return true; - default: - return false; - } - } - bool lowerCall(const CallInst *I); /// Select and emit code for a binary operator instruction, which has /// an opcode which directly corresponds to the given ISD opcode. diff --git a/include/llvm/IR/IntrinsicInst.h b/include/llvm/IR/IntrinsicInst.h index 01ea5dcb814..c29d20c1729 100644 --- a/include/llvm/IR/IntrinsicInst.h +++ b/include/llvm/IR/IntrinsicInst.h @@ -54,7 +54,7 @@ public: /// Return true if swapping the first two arguments to the intrinsic produces /// the same result. - bool isCommutative() { + bool isCommutative() const { switch (getIntrinsicID()) { case Intrinsic::maxnum: case Intrinsic::minnum: diff --git a/lib/Target/AArch64/AArch64FastISel.cpp b/lib/Target/AArch64/AArch64FastISel.cpp index f0b35c2aef2..9801036653f 100644 --- a/lib/Target/AArch64/AArch64FastISel.cpp +++ b/lib/Target/AArch64/AArch64FastISel.cpp @@ -3409,8 +3409,7 @@ bool AArch64FastISel::foldXALUIntrinsic(AArch64CC::CondCode &CC, const Value *RHS = II->getArgOperand(1); // Canonicalize immediate to the RHS. - if (isa(LHS) && !isa(RHS) && - isCommutativeIntrinsic(II)) + if (isa(LHS) && !isa(RHS) && II->isCommutative()) std::swap(LHS, RHS); // Simplify multiplies. @@ -3697,8 +3696,7 @@ bool AArch64FastISel::fastLowerIntrinsicCall(const IntrinsicInst *II) { const Value *LHS = II->getArgOperand(0); const Value *RHS = II->getArgOperand(1); // Canonicalize immediate to the RHS. - if (isa(LHS) && !isa(RHS) && - isCommutativeIntrinsic(II)) + if (isa(LHS) && !isa(RHS) && II->isCommutative()) std::swap(LHS, RHS); // Simplify multiplies. diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp index f0bd821f77d..39a3557f323 100644 --- a/lib/Target/X86/X86FastISel.cpp +++ b/lib/Target/X86/X86FastISel.cpp @@ -2879,8 +2879,7 @@ bool X86FastISel::fastLowerIntrinsicCall(const IntrinsicInst *II) { const Value *RHS = II->getArgOperand(1); // Canonicalize immediate to the RHS. - if (isa(LHS) && !isa(RHS) && - isCommutativeIntrinsic(II)) + if (isa(LHS) && !isa(RHS) && II->isCommutative()) std::swap(LHS, RHS); unsigned BaseOpc, CondCode;