[llvm] 5599c43 - GlobalISel: Swap order of operand checks in ConstantFoldVectorBinop
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 18 14:21:13 PST 2022
Author: Matt Arsenault
Date: 2022-01-18T17:21:02-05:00
New Revision: 5599c43124c5ba70738494466ea3dc722759274c
URL: https://github.com/llvm/llvm-project/commit/5599c43124c5ba70738494466ea3dc722759274c
DIFF: https://github.com/llvm/llvm-project/commit/5599c43124c5ba70738494466ea3dc722759274c.diff
LOG: GlobalISel: Swap order of operand checks in ConstantFoldVectorBinop
Since constants are canonicalized to the RHS, this is more likely to
exit early.
Added:
Modified:
llvm/lib/CodeGen/GlobalISel/Utils.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/Utils.cpp b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
index 5cdf9be16c06..544af9a2954f 100644
--- a/llvm/lib/CodeGen/GlobalISel/Utils.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
@@ -596,13 +596,14 @@ Register llvm::ConstantFoldVectorBinop(unsigned Opcode, const Register Op1,
const Register Op2,
const MachineRegisterInfo &MRI,
MachineIRBuilder &MIB) {
- auto *SrcVec1 = getOpcodeDef<GBuildVector>(Op1, MRI);
- if (!SrcVec1)
- return Register();
auto *SrcVec2 = getOpcodeDef<GBuildVector>(Op2, MRI);
if (!SrcVec2)
return Register();
+ auto *SrcVec1 = getOpcodeDef<GBuildVector>(Op1, MRI);
+ if (!SrcVec1)
+ return Register();
+
const LLT EltTy = MRI.getType(SrcVec1->getSourceReg(0));
SmallVector<Register, 16> FoldedElements;
More information about the llvm-commits
mailing list