From cec249c60dad84574fd53d2fbf158bfeef226777 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 12 May 2022 00:32:45 -0700 Subject: [TypePromotion] Promote undef by converting to 0. If we're promoting an undef I think that means that we expect the upper bits are zero. undef doesn't guarantee that. This patch replaces undef with 0 to ensure this. This matches how a zext or sext of undef would be folded by InstCombine/InstSimplify. I haven't found a failure from this was just thinking through the code. Differential Revision: https://reviews.llvm.org/D123174 --- llvm/lib/CodeGen/TypePromotion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/TypePromotion.cpp') diff --git a/llvm/lib/CodeGen/TypePromotion.cpp b/llvm/lib/CodeGen/TypePromotion.cpp index fa7c797c70f0..cb0d99326201 100644 --- a/llvm/lib/CodeGen/TypePromotion.cpp +++ b/llvm/lib/CodeGen/TypePromotion.cpp @@ -489,7 +489,7 @@ void IRPromoter::PromoteTree() { : ConstantExpr::getZExt(Const, ExtTy); I->setOperand(i, NewConst); } else if (isa(Op)) - I->setOperand(i, UndefValue::get(ExtTy)); + I->setOperand(i, ConstantInt::get(ExtTy, 0)); } // Mutate the result type, unless this is an icmp or switch. -- cgit v1.2.3