[llvm] [InstCombine][VectorCombine][NFC] Unify uses of lossless inverse cast (PR #156597)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 3 02:32:02 PDT 2025


================
@@ -1799,16 +1799,19 @@ static Instruction *foldLogicCastConstant(BinaryOperator &Logic, CastInst *Cast,
   // type may provide more information to later folds, and the smaller logic
   // instruction may be cheaper (particularly in the case of vectors).
   Value *X;
+  auto &DL = IC.getDataLayout();
   if (match(Cast, m_OneUse(m_ZExt(m_Value(X))))) {
-    if (Constant *TruncC = IC.getLosslessUnsignedTrunc(C, SrcTy)) {
+    if (Constant *TruncC =
+            getLosslessInvCast(C, SrcTy, Instruction::ZExt, DL)) {
----------------
nikic wrote:

Also remove the old helper functions, which are presumably unused now?

TBH I find the new API super confusing. This is doing a truncate, but it's phrased in terms of a ZExt.

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


More information about the llvm-commits mailing list