[llvm] [GlobalIsel] Combine freeze (PR #93239)

Thorsten Schütt via llvm-commits llvm-commits at lists.llvm.org
Sat May 25 08:27:20 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:

It is the source of a constant vector. If the shift type is a vector, we need to check the vector shift amount aka G_BUILD_VECTOR.

https://github.com/llvm/llvm-project/pull/93239


More information about the llvm-commits mailing list