[llvm] [ValueTracking] Improve `isImpliedCondCommonOperandWithConstants` to handle truncated LHS (PR #69829)

via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 21 22:47:20 PDT 2023


================
@@ -8272,8 +8288,19 @@ static std::optional<bool> isImpliedCondICmps(const ICmpInst *LHS,
   // Can we infer anything when the 0-operands match and the 1-operands are
   // constants (not necessarily matching)?
   const APInt *LC, *RC;
-  if (L0 == R0 && match(L1, m_APInt(LC)) && match(R1, m_APInt(RC)))
-    return isImpliedCondCommonOperandWithConstants(LPred, *LC, RPred, *RC);
+  if (match(L1, m_APInt(LC)) && match(R1, m_APInt(RC))) {
+    if (auto Res = isImpliedCondCommonOperandWithConstants(L0, LPred, *LC, R0,
+                                                           RPred, *RC))
+      return Res;
+
+    if (match(L0, m_Trunc(m_Specific(R0)))) {
----------------
goldsteinn wrote:

Isn't this covered by the `match(L0, m_Trunc(R0))...` above?

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


More information about the llvm-commits mailing list