[llvm] 2d3e128 - [FastISel] update to use intrinsic's isCommutative(); NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 30 08:39:31 PDT 2020
Author: Sanjay Patel
Date: 2020-08-30T11:36:41-04:00
New Revision: 2d3e12818e6e2466052db41833d1d564628ecfc9
URL: https://github.com/llvm/llvm-project/commit/2d3e12818e6e2466052db41833d1d564628ecfc9
DIFF: https://github.com/llvm/llvm-project/commit/2d3e12818e6e2466052db41833d1d564628ecfc9.diff
LOG: [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
Added:
Modified:
llvm/include/llvm/CodeGen/FastISel.h
llvm/include/llvm/IR/IntrinsicInst.h
llvm/lib/Target/AArch64/AArch64FastISel.cpp
llvm/lib/Target/X86/X86FastISel.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/FastISel.h b/llvm/include/llvm/CodeGen/FastISel.h
index 7662179db44d..5c1ebc7af177 100644
--- a/llvm/include/llvm/CodeGen/FastISel.h
+++ b/llvm/include/llvm/CodeGen/FastISel.h
@@ -510,18 +510,6 @@ class FastISel {
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/llvm/include/llvm/IR/IntrinsicInst.h b/llvm/include/llvm/IR/IntrinsicInst.h
index 01ea5dcb8140..c29d20c1729b 100644
--- a/llvm/include/llvm/IR/IntrinsicInst.h
+++ b/llvm/include/llvm/IR/IntrinsicInst.h
@@ -54,7 +54,7 @@ class IntrinsicInst : public CallInst {
/// 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/llvm/lib/Target/AArch64/AArch64FastISel.cpp b/llvm/lib/Target/AArch64/AArch64FastISel.cpp
index f0b35c2aef26..9801036653f7 100644
--- a/llvm/lib/Target/AArch64/AArch64FastISel.cpp
+++ b/llvm/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<ConstantInt>(LHS) && !isa<ConstantInt>(RHS) &&
- isCommutativeIntrinsic(II))
+ if (isa<ConstantInt>(LHS) && !isa<ConstantInt>(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<ConstantInt>(LHS) && !isa<ConstantInt>(RHS) &&
- isCommutativeIntrinsic(II))
+ if (isa<ConstantInt>(LHS) && !isa<ConstantInt>(RHS) && II->isCommutative())
std::swap(LHS, RHS);
// Simplify multiplies.
diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp
index f0bd821f77d0..39a3557f3236 100644
--- a/llvm/lib/Target/X86/X86FastISel.cpp
+++ b/llvm/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<ConstantInt>(LHS) && !isa<ConstantInt>(RHS) &&
- isCommutativeIntrinsic(II))
+ if (isa<ConstantInt>(LHS) && !isa<ConstantInt>(RHS) && II->isCommutative())
std::swap(LHS, RHS);
unsigned BaseOpc, CondCode;
More information about the llvm-commits
mailing list