[llvm] [GlobalIsel] Combine freeze (PR #93239)
Dhruv Chawla via llvm-commits
llvm-commits at lists.llvm.org
Sat May 25 08:21:01 PDT 2024
Thorsten =?utf-8?q?Schütt?= <schuett at gmail.com>,
Thorsten =?utf-8?q?Schütt?= <schuett at gmail.com>,
Thorsten =?utf-8?q?Schütt?= <schuett at gmail.com>,
Thorsten =?utf-8?q?Schütt?= <schuett at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/93239 at github.com>
================
@@ -1724,6 +1724,39 @@ bool llvm::isPreISelGenericFloatingPointOpcode(unsigned Opc) {
}
}
+/// Shifts return poison if shiftwidth is larger than the bitwidth.
+static bool shiftAmountKnownInRange(Register ShiftAmount,
+ const MachineRegisterInfo &MRI) {
+ LLT Ty = MRI.getType(ShiftAmount);
+
+ if (Ty.isScalableVector())
+ return false; // Can't tell, just return false to be safe
+
+ if (Ty.isScalar()) {
+ std::optional<ValueAndVReg> Val =
+ getIConstantVRegValWithLookThrough(ShiftAmount, MRI);
+ if (!Val)
+ return false;
+ return Val->Value.ult(Ty.getScalarSizeInBits());
+ }
+
+ GBuildVector *BV = getOpcodeDef<GBuildVector>(ShiftAmount, MRI);
+ if (!BV)
+ return false;
+
+ unsigned Sources = BV->getNumSources();
----------------
dc03-work wrote:
Should add a comment explaining why `GBuildVector` specifically is being checked.
https://github.com/llvm/llvm-project/pull/93239
More information about the llvm-commits
mailing list