[llvm] [GlobalIsel] Combine freeze (PR #93239)
Thorsten Schütt via llvm-commits
llvm-commits at lists.llvm.org
Sat May 25 09:38:59 PDT 2024
================
@@ -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();
----------------
tschuett wrote:
See https://github.com/llvm/llvm-project/blob/d776346afe790e5d51ca6c6e2238a6ba91d130a1/llvm/lib/Analysis/ValueTracking.cpp#L7010
and
https://github.com/llvm/llvm-project/blob/53b904823cba4e93d58793b0804407f812477724/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp#L3073
https://github.com/llvm/llvm-project/pull/93239
More information about the llvm-commits
mailing list