[llvm] [IR] Remove zext and sext constant expressions (PR #71040)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 2 02:45:38 PDT 2023
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/71040
Remove support for zext and sext constant expressions. All places creating them have been removed beforehand, so this just removes the APIs and uses of these constant expressions in tests.
There is some additional cleanup that can be done on top of this, e.g. we can remove the ZExtInst vs ZExtOperator footgun.
This is part of https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179.
>From e593880e8e2c4280c1bca9a4933ec7f9eb996cd8 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Wed, 1 Nov 2023 14:58:49 +0100
Subject: [PATCH] [IR] Remove zext and sext constant expressions
Remove support for zext and sext constant expressions. All places
creating them have been removed beforehand, so this just removes
the APIs and uses of these constant expressions in tests.
There is some additional cleanup that can be done on top of this,
e.g. we can remove the ZExtInst vs ZExtOperator footgun.
This is part of
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179.
---
llvm/bindings/ocaml/llvm/llvm.ml | 8 --
llvm/bindings/ocaml/llvm/llvm.mli | 27 ------
llvm/bindings/ocaml/llvm/llvm_ocaml.c | 30 ------
llvm/docs/ReleaseNotes.rst | 7 ++
llvm/include/llvm-c/Core.h | 8 --
llvm/include/llvm/IR/Constants.h | 29 +-----
llvm/lib/AsmParser/LLParser.cpp | 6 +-
llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 3 +
llvm/lib/IR/ConstantFold.cpp | 72 ---------------
llvm/lib/IR/Constants.cpp | 91 +++++--------------
llvm/lib/IR/Core.cpp | 28 ------
.../Lint/noop-cast-expr-no-pointer.ll | 6 +-
.../ptrtoint-constantexpr-loop.ll | 24 +++--
.../Assembler/2009-03-24-ZextConstantExpr.ll | 12 ---
llvm/test/Bindings/OCaml/core.ml | 7 --
.../AArch64/arm64-2012-05-09-LOADgot-bug.ll | 3 +-
.../AArch64/arm64-codegen-prepare-extload.ll | 8 +-
.../GlobalISel/irtranslator-constantexpr.ll | 12 +--
.../CodeGen/ARM/2007-04-03-UndefinedSymbol.ll | 90 +++++++++++-------
.../CodeGen/ARM/2012-01-23-PostRA-LICM.ll | 46 +++++++---
llvm/test/CodeGen/ARM/2018-02-13-PR36079.ll | 19 +++-
.../Hexagon/opt-addr-mode-subreg-use.ll | 18 ++--
.../test/CodeGen/Hexagon/packetize-l2fetch.ll | 3 +-
.../CodeGen/PowerPC/ext-bool-trunc-repl.ll | 32 ++++---
.../CodeGen/WebAssembly/fast-isel-noreg.ll | 6 +-
.../CodeGen/X86/2008-09-19-RegAllocBug.ll | 4 +-
.../X86/2012-03-20-LargeConstantExpr.ll | 17 ----
llvm/test/CodeGen/X86/absolute-constant.ll | 3 +-
llvm/test/CodeGen/X86/absolute-rotate.ll | 12 ++-
.../address-type-promotion-constantexpr.ll | 3 +-
.../CodeGen/X86/codegen-prepare-extload.ll | 10 +-
llvm/test/CodeGen/X86/fast-isel-expect.ll | 3 +-
llvm/test/Feature/constexpr.ll | 2 +-
llvm/test/Feature/newcasts.ll | 9 --
.../Feature/vector-cast-constant-exprs.ll | 6 --
llvm/test/Integer/constexpr_bt.ll | 2 +-
llvm/test/Integer/newcasts_bt.ll | 9 --
.../GlobalDCE/complex-constantexpr.ll | 5 +-
.../GlobalOpt/dead-constant-user.ll | 2 +-
...004-11-27-SetCCForCastLargerAndConstant.ll | 3 +-
.../InstCombine/2012-3-15-or-xor-constant.ll | 3 +-
.../InstCombine/constant-fold-compare.ll | 3 +-
.../InstCombine/constant-fold-iteration.ll | 3 +-
.../InstCombine/fold-bin-operand.ll | 3 +-
llvm/test/Transforms/InstCombine/icmp-mul.ll | 3 +-
llvm/test/Transforms/InstCombine/icmp.ll | 10 +-
.../InstCombine/mul-inseltpoison.ll | 9 +-
llvm/test/Transforms/InstCombine/mul.ll | 9 +-
llvm/test/Transforms/InstCombine/not-add.ll | 3 +-
.../Transforms/InstCombine/overflow-mul.ll | 3 +-
llvm/test/Transforms/InstCombine/pr32686.ll | 8 +-
llvm/test/Transforms/InstCombine/pr35515.ll | 6 +-
llvm/test/Transforms/InstCombine/rem.ll | 6 +-
.../shift-amount-reassociation-in-bittest.ll | 9 +-
.../Transforms/InstCombine/udiv-simplify.ll | 6 +-
.../InstCombine/udivrem-change-width.ll | 27 ++++--
.../InstSimplify/ConstProp/constant-expr.ll | 7 --
.../JumpThreading/constant-fold-status.ll | 2 +-
llvm/test/Transforms/SCCP/undef-resolve.ll | 22 +++--
.../SLPVectorizer/X86/bad-reduction.ll | 16 +++-
llvm/unittests/IR/ConstantsTest.cpp | 2 -
61 files changed, 347 insertions(+), 498 deletions(-)
delete mode 100644 llvm/test/Assembler/2009-03-24-ZextConstantExpr.ll
delete mode 100644 llvm/test/CodeGen/X86/2012-03-20-LargeConstantExpr.ll
diff --git a/llvm/bindings/ocaml/llvm/llvm.ml b/llvm/bindings/ocaml/llvm/llvm.ml
index a768d10d5d4dc9b..cabf32cae376f22 100644
--- a/llvm/bindings/ocaml/llvm/llvm.ml
+++ b/llvm/bindings/ocaml/llvm/llvm.ml
@@ -661,8 +661,6 @@ external const_gep : lltype -> llvalue -> llvalue array -> llvalue
external const_in_bounds_gep : lltype -> llvalue -> llvalue array -> llvalue
= "llvm_const_in_bounds_gep"
external const_trunc : llvalue -> lltype -> llvalue = "llvm_const_trunc"
-external const_sext : llvalue -> lltype -> llvalue = "llvm_const_sext"
-external const_zext : llvalue -> lltype -> llvalue = "llvm_const_zext"
external const_fptrunc : llvalue -> lltype -> llvalue = "llvm_const_fptrunc"
external const_fpext : llvalue -> lltype -> llvalue = "llvm_const_fpext"
external const_uitofp : llvalue -> lltype -> llvalue = "llvm_const_uitofp"
@@ -672,16 +670,10 @@ external const_fptosi : llvalue -> lltype -> llvalue = "llvm_const_fptosi"
external const_ptrtoint : llvalue -> lltype -> llvalue = "llvm_const_ptrtoint"
external const_inttoptr : llvalue -> lltype -> llvalue = "llvm_const_inttoptr"
external const_bitcast : llvalue -> lltype -> llvalue = "llvm_const_bitcast"
-external const_zext_or_bitcast : llvalue -> lltype -> llvalue
- = "llvm_const_zext_or_bitcast"
-external const_sext_or_bitcast : llvalue -> lltype -> llvalue
- = "llvm_const_sext_or_bitcast"
external const_trunc_or_bitcast : llvalue -> lltype -> llvalue
= "llvm_const_trunc_or_bitcast"
external const_pointercast : llvalue -> lltype -> llvalue
= "llvm_const_pointercast"
-external const_intcast : llvalue -> lltype -> is_signed:bool -> llvalue
- = "llvm_const_intcast"
external const_fpcast : llvalue -> lltype -> llvalue = "llvm_const_fpcast"
external const_extractelement : llvalue -> llvalue -> llvalue
= "llvm_const_extractelement"
diff --git a/llvm/bindings/ocaml/llvm/llvm.mli b/llvm/bindings/ocaml/llvm/llvm.mli
index 9e85f01df383596..ee691ca83624455 100644
--- a/llvm/bindings/ocaml/llvm/llvm.mli
+++ b/llvm/bindings/ocaml/llvm/llvm.mli
@@ -1171,16 +1171,6 @@ val const_in_bounds_gep : lltype -> llvalue -> llvalue array -> llvalue
See the method [llvm::ConstantExpr::getTrunc]. *)
val const_trunc : llvalue -> lltype -> llvalue
-(** [const_sext c ty] returns the constant sign extension of integer constant
- [c] to the larger integer type [ty].
- See the method [llvm::ConstantExpr::getSExt]. *)
-val const_sext : llvalue -> lltype -> llvalue
-
-(** [const_zext c ty] returns the constant zero extension of integer constant
- [c] to the larger integer type [ty].
- See the method [llvm::ConstantExpr::getZExt]. *)
-val const_zext : llvalue -> lltype -> llvalue
-
(** [const_fptrunc c ty] returns the constant truncation of floating point
constant [c] to the smaller floating point type [ty].
See the method [llvm::ConstantExpr::getFPTrunc]. *)
@@ -1226,16 +1216,6 @@ val const_inttoptr : llvalue -> lltype -> llvalue
See the method [llvm::ConstantExpr::getBitCast]. *)
val const_bitcast : llvalue -> lltype -> llvalue
-(** [const_zext_or_bitcast c ty] returns a constant zext or bitwise cast
- conversion of constant [c] to type [ty].
- See the method [llvm::ConstantExpr::getZExtOrBitCast]. *)
-val const_zext_or_bitcast : llvalue -> lltype -> llvalue
-
-(** [const_sext_or_bitcast c ty] returns a constant sext or bitwise cast
- conversion of constant [c] to type [ty].
- See the method [llvm::ConstantExpr::getSExtOrBitCast]. *)
-val const_sext_or_bitcast : llvalue -> lltype -> llvalue
-
(** [const_trunc_or_bitcast c ty] returns a constant trunc or bitwise cast
conversion of constant [c] to type [ty].
See the method [llvm::ConstantExpr::getTruncOrBitCast]. *)
@@ -1246,13 +1226,6 @@ val const_trunc_or_bitcast : llvalue -> lltype -> llvalue
See the method [llvm::ConstantExpr::getPointerCast]. *)
val const_pointercast : llvalue -> lltype -> llvalue
-(** [const_intcast c ty ~is_signed] returns a constant sext/zext, bitcast,
- or trunc for integer -> integer casts of constant [c] to type [ty].
- When converting a narrower value to a wider one, whether sext or zext
- will be used is controlled by [is_signed].
- See the method [llvm::ConstantExpr::getIntegerCast]. *)
-val const_intcast : llvalue -> lltype -> is_signed:bool -> llvalue
-
(** [const_fpcast c ty] returns a constant fpext, bitcast, or fptrunc for fp ->
fp casts of constant [c] to type [ty].
See the method [llvm::ConstantExpr::getFPCast]. *)
diff --git a/llvm/bindings/ocaml/llvm/llvm_ocaml.c b/llvm/bindings/ocaml/llvm/llvm_ocaml.c
index f0e47a31af03d7b..7c5df6643d21a8a 100644
--- a/llvm/bindings/ocaml/llvm/llvm_ocaml.c
+++ b/llvm/bindings/ocaml/llvm/llvm_ocaml.c
@@ -1271,18 +1271,6 @@ value llvm_const_trunc(value CV, value T) {
return to_val(Value);
}
-/* llvalue -> lltype -> llvalue */
-value llvm_const_sext(value CV, value T) {
- LLVMValueRef Value = LLVMConstSExt(Value_val(CV), Type_val(T));
- return to_val(Value);
-}
-
-/* llvalue -> lltype -> llvalue */
-value llvm_const_zext(value CV, value T) {
- LLVMValueRef Value = LLVMConstZExt(Value_val(CV), Type_val(T));
- return to_val(Value);
-}
-
/* llvalue -> lltype -> llvalue */
value llvm_const_fptrunc(value CV, value T) {
LLVMValueRef Value = LLVMConstFPTrunc(Value_val(CV), Type_val(T));
@@ -1337,18 +1325,6 @@ value llvm_const_bitcast(value CV, value T) {
return to_val(Value);
}
-/* llvalue -> lltype -> llvalue */
-value llvm_const_zext_or_bitcast(value CV, value T) {
- LLVMValueRef Value = LLVMConstZExtOrBitCast(Value_val(CV), Type_val(T));
- return to_val(Value);
-}
-
-/* llvalue -> lltype -> llvalue */
-value llvm_const_sext_or_bitcast(value CV, value T) {
- LLVMValueRef Value = LLVMConstSExtOrBitCast(Value_val(CV), Type_val(T));
- return to_val(Value);
-}
-
/* llvalue -> lltype -> llvalue */
value llvm_const_trunc_or_bitcast(value CV, value T) {
LLVMValueRef Value = LLVMConstTruncOrBitCast(Value_val(CV), Type_val(T));
@@ -1361,12 +1337,6 @@ value llvm_const_pointercast(value CV, value T) {
return to_val(Value);
}
-/* llvalue -> lltype -> is_signed:bool -> llvalue */
-value llvm_const_intcast(value CV, value T, value IsSigned) {
- return to_val(
- LLVMConstIntCast(Value_val(CV), Type_val(T), Bool_val(IsSigned)));
-}
-
/* llvalue -> lltype -> llvalue */
value llvm_const_fpcast(value CV, value T) {
LLVMValueRef Value = LLVMConstFPCast(Value_val(CV), Type_val(T));
diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 25817e6e1d7f413..23b54e6a37a7451 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -57,6 +57,8 @@ Changes to the LLVM IR
* ``and``
* ``or``
+ * ``zext``
+ * ``sext``
* Added `llvm.exp10` intrinsic.
@@ -166,6 +168,11 @@ Changes to the C API
* ``LLVMConstAnd``
* ``LLVMConstOr``
+ * ``LLVMConstZExt``
+ * ``LLVMConstSExt``
+ * ``LLVMConstZExtOrBitCast``
+ * ``LLVMConstSExtOrBitCast``
+ * ``LLVMConstIntCast``
* Added ``LLVMCreateTargetMachineWithOptions``, along with helper functions for
an opaque option structure, as an alternative to ``LLVMCreateTargetMachine``.
diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index 7ee46cac43042a1..4fc88b2b64eacea 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-c/Core.h
@@ -2290,8 +2290,6 @@ LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
LLVMValueRef *ConstantIndices,
unsigned NumIndices);
LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
-LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
-LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
@@ -2302,16 +2300,10 @@ LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
-LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
- LLVMTypeRef ToType);
-LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
- LLVMTypeRef ToType);
LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
LLVMTypeRef ToType);
LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
LLVMTypeRef ToType);
-LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
- LLVMBool isSigned);
LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType);
LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant,
LLVMValueRef IndexConstant);
diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h
index afa1aefb44aa1aa..43744ba8a617812 100644
--- a/llvm/include/llvm/IR/Constants.h
+++ b/llvm/include/llvm/IR/Constants.h
@@ -1041,8 +1041,6 @@ class ConstantExpr : public Constant {
static Constant *getLShr(Constant *C1, Constant *C2, bool isExact = false);
static Constant *getAShr(Constant *C1, Constant *C2, bool isExact = false);
static Constant *getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced = false);
- static Constant *getSExt(Constant *C, Type *Ty, bool OnlyIfReduced = false);
- static Constant *getZExt(Constant *C, Type *Ty, bool OnlyIfReduced = false);
static Constant *getFPTrunc(Constant *C, Type *Ty,
bool OnlyIfReduced = false);
static Constant *getFPExtend(Constant *C, Type *Ty,
@@ -1140,29 +1138,12 @@ class ConstantExpr : public Constant {
static Constant *getCast(unsigned ops, Constant *C, Type *Ty,
bool OnlyIfReduced = false);
- // Create a ZExt or BitCast cast constant expression
- static Constant *
- getZExtOrBitCast(Constant *C, ///< The constant to zext or bitcast
- Type *Ty ///< The type to zext or bitcast C to
- );
-
- // Create a SExt or BitCast cast constant expression
- static Constant *
- getSExtOrBitCast(Constant *C, ///< The constant to sext or bitcast
- Type *Ty ///< The type to sext or bitcast C to
- );
-
// Create a Trunc or BitCast cast constant expression
static Constant *
getTruncOrBitCast(Constant *C, ///< The constant to trunc or bitcast
Type *Ty ///< The type to trunc or bitcast C to
);
- /// Create either an sext, trunc or nothing, depending on whether Ty is
- /// wider, narrower or the same as C->getType(). This only works with
- /// integer or vector of integer types.
- static Constant *getSExtOrTrunc(Constant *C, Type *Ty);
-
/// Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant
/// expression.
static Constant *
@@ -1177,13 +1158,6 @@ class ConstantExpr : public Constant {
Type *Ty ///< The type to bitcast or addrspacecast C to
);
- /// Create a ZExt, Bitcast or Trunc for integer -> integer casts
- static Constant *
- getIntegerCast(Constant *C, ///< The integer constant to be casted
- Type *Ty, ///< The integer type to cast to
- bool IsSigned ///< Whether C should be treated as signed or not
- );
-
/// Create a FPExt, Bitcast or FPTrunc for fp -> fp casts
static Constant *getFPCast(Constant *C, ///< The integer constant to be casted
Type *Ty ///< The integer type to cast to
@@ -1333,6 +1307,9 @@ class ConstantExpr : public Constant {
/// Whether creating a constant expression for this cast is desirable.
static bool isDesirableCastOp(unsigned Opcode);
+ /// Whether creating a constant expression for this cast is supported.
+ static bool isSupportedCastOp(unsigned Opcode);
+
/// Whether creating a constant expression for this getelementptr type is
/// supported.
static bool isSupportedGetElementPtr(const Type *SrcElemTy) {
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 42f306a99d5eefa..d3abd16204a4534 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -3805,8 +3805,6 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
}
case lltok::kw_trunc:
- case lltok::kw_zext:
- case lltok::kw_sext:
case lltok::kw_fptrunc:
case lltok::kw_fpext:
case lltok::kw_bitcast:
@@ -3866,6 +3864,10 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
return error(ID.Loc, "fneg constexprs are no longer supported");
case lltok::kw_select:
return error(ID.Loc, "select constexprs are no longer supported");
+ case lltok::kw_zext:
+ return error(ID.Loc, "zext constexprs are no longer supported");
+ case lltok::kw_sext:
+ return error(ID.Loc, "sext constexprs are no longer supported");
case lltok::kw_icmp:
case lltok::kw_fcmp: {
unsigned PredVal, Opc = Lex.getUIntVal();
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 747968b51407cd9..1c92da5a49a7872 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1394,6 +1394,9 @@ static bool isConstExprSupported(const BitcodeConstant *BC) {
if (Instruction::isBinaryOp(Opcode))
return ConstantExpr::isSupportedBinOp(Opcode);
+ if (Instruction::isCast(Opcode))
+ return ConstantExpr::isSupportedCastOp(Opcode);
+
if (Opcode == Instruction::GetElementPtr)
return ConstantExpr::isSupportedGetElementPtr(BC->SrcElemTy);
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 15a74859045183b..81691a5f69aa0a6 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -258,40 +258,6 @@ static Constant *ExtractConstantBytes(Constant *C, unsigned ByteStart,
// TODO: Handle the 'partially zero' case.
return nullptr;
}
-
- case Instruction::ZExt: {
- unsigned SrcBitSize =
- cast<IntegerType>(CE->getOperand(0)->getType())->getBitWidth();
-
- // If extracting something that is completely zero, return 0.
- if (ByteStart*8 >= SrcBitSize)
- return Constant::getNullValue(IntegerType::get(CE->getContext(),
- ByteSize*8));
-
- // If exactly extracting the input, return it.
- if (ByteStart == 0 && ByteSize*8 == SrcBitSize)
- return CE->getOperand(0);
-
- // If extracting something completely in the input, if the input is a
- // multiple of 8 bits, recurse.
- if ((SrcBitSize&7) == 0 && (ByteStart+ByteSize)*8 <= SrcBitSize)
- return ExtractConstantBytes(CE->getOperand(0), ByteStart, ByteSize);
-
- // Otherwise, if extracting a subset of the input, which is not multiple of
- // 8 bits, do a shift and trunc to get the bits.
- if ((ByteStart+ByteSize)*8 < SrcBitSize) {
- assert((SrcBitSize&7) && "Shouldn't get byte sized case here");
- Constant *Res = CE->getOperand(0);
- if (ByteStart)
- Res = ConstantExpr::getLShr(Res,
- ConstantInt::get(Res->getType(), ByteStart*8));
- return ConstantExpr::getTrunc(Res, IntegerType::get(C->getContext(),
- ByteSize*8));
- }
-
- // TODO: Handle the 'partially zero' case.
- return nullptr;
- }
}
}
@@ -986,16 +952,6 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
return C1; // X & -1 == X
if (ConstantExpr *CE1 = dyn_cast<ConstantExpr>(C1)) {
- // (zext i32 to i64) & 4294967295 -> (zext i32 to i64)
- if (CE1->getOpcode() == Instruction::ZExt) {
- unsigned DstWidth = CI2->getType()->getBitWidth();
- unsigned SrcWidth =
- CE1->getOperand(0)->getType()->getPrimitiveSizeInBits();
- APInt PossiblySetBits(APInt::getLowBitsSet(DstWidth, SrcWidth));
- if ((PossiblySetBits & CI2->getValue()) == PossiblySetBits)
- return C1;
- }
-
// If and'ing the address of a global with a constant, fold it.
if (CE1->getOpcode() == Instruction::PtrToInt &&
isa<GlobalValue>(CE1->getOperand(0))) {
@@ -1056,12 +1012,6 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
}
}
break;
- case Instruction::AShr:
- // ashr (zext C to Ty), C2 -> lshr (zext C, CSA), C2
- if (ConstantExpr *CE1 = dyn_cast<ConstantExpr>(C1))
- if (CE1->getOpcode() == Instruction::ZExt) // Top bits known zero.
- return ConstantExpr::getLShr(C1, C2);
- break;
}
} else if (isa<ConstantInt>(C1)) {
// If C1 is a ConstantInt and C2 is not, swap the operands.
@@ -1461,8 +1411,6 @@ static ICmpInst::Predicate evaluateICmpRelation(Constant *V1, Constant *V2,
[[fallthrough]];
case Instruction::UIToFP:
case Instruction::SIToFP:
- case Instruction::ZExt:
- case Instruction::SExt:
// We can't evaluate floating point casts or truncations.
if (CE1Op0->getType()->isFPOrFPVectorTy())
break;
@@ -1470,8 +1418,6 @@ static ICmpInst::Predicate evaluateICmpRelation(Constant *V1, Constant *V2,
// If the cast is not actually changing bits, and the second operand is a
// null pointer, do the comparison with the pre-casted value.
if (V2->isNullValue() && CE1->getType()->isIntOrPtrTy()) {
- if (CE1->getOpcode() == Instruction::ZExt) isSigned = false;
- if (CE1->getOpcode() == Instruction::SExt) isSigned = true;
return evaluateICmpRelation(CE1Op0,
Constant::getNullValue(CE1Op0->getType()),
isSigned);
@@ -1828,24 +1774,6 @@ Constant *llvm::ConstantFoldCompareInstruction(CmpInst::Predicate Predicate,
}
}
- // If the left hand side is an extension, try eliminating it.
- if (ConstantExpr *CE1 = dyn_cast<ConstantExpr>(C1)) {
- if ((CE1->getOpcode() == Instruction::SExt &&
- ICmpInst::isSigned(Predicate)) ||
- (CE1->getOpcode() == Instruction::ZExt &&
- !ICmpInst::isSigned(Predicate))) {
- Constant *CE1Op0 = CE1->getOperand(0);
- Constant *CE1Inverse = ConstantExpr::getTrunc(CE1, CE1Op0->getType());
- if (CE1Inverse == CE1Op0) {
- // Check whether we can safely truncate the right hand side.
- Constant *C2Inverse = ConstantExpr::getTrunc(C2, CE1Op0->getType());
- if (ConstantExpr::getCast(CE1->getOpcode(), C2Inverse,
- C2->getType()) == C2)
- return ConstantExpr::getICmp(Predicate, CE1Inverse, C2Inverse);
- }
- }
- }
-
if ((!isa<ConstantExpr>(C1) && isa<ConstantExpr>(C2)) ||
(C1->isNullValue() && !C2->isNullValue())) {
// If C2 is a constant expr and C1 isn't, flip them around and fold the
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index 58cbde1bfb530df..cca481181068d7e 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -1958,6 +1958,8 @@ Constant *ConstantExpr::getCast(unsigned oc, Constant *C, Type *Ty,
bool OnlyIfReduced) {
Instruction::CastOps opc = Instruction::CastOps(oc);
assert(Instruction::isCast(opc) && "opcode out of range");
+ assert(isSupportedCastOp(opc) &&
+ "Cast opcode not supported as constant expression");
assert(C && Ty && "Null arguments to getCast");
assert(CastInst::castIsValid(opc, C, Ty) && "Invalid constantexpr cast!");
@@ -1966,10 +1968,6 @@ Constant *ConstantExpr::getCast(unsigned oc, Constant *C, Type *Ty,
llvm_unreachable("Invalid cast opcode");
case Instruction::Trunc:
return getTrunc(C, Ty, OnlyIfReduced);
- case Instruction::ZExt:
- return getZExt(C, Ty, OnlyIfReduced);
- case Instruction::SExt:
- return getSExt(C, Ty, OnlyIfReduced);
case Instruction::FPTrunc:
return getFPTrunc(C, Ty, OnlyIfReduced);
case Instruction::FPExt:
@@ -1993,35 +1991,12 @@ Constant *ConstantExpr::getCast(unsigned oc, Constant *C, Type *Ty,
}
}
-Constant *ConstantExpr::getZExtOrBitCast(Constant *C, Type *Ty) {
- if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
- return getBitCast(C, Ty);
- return getZExt(C, Ty);
-}
-
-Constant *ConstantExpr::getSExtOrBitCast(Constant *C, Type *Ty) {
- if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
- return getBitCast(C, Ty);
- return getSExt(C, Ty);
-}
-
Constant *ConstantExpr::getTruncOrBitCast(Constant *C, Type *Ty) {
if (C->getType()->getScalarSizeInBits() == Ty->getScalarSizeInBits())
return getBitCast(C, Ty);
return getTrunc(C, Ty);
}
-Constant *ConstantExpr::getSExtOrTrunc(Constant *C, Type *Ty) {
- assert(C->getType()->isIntOrIntVectorTy() && Ty->isIntOrIntVectorTy() &&
- "Can only sign extend/truncate integers!");
- Type *CTy = C->getType();
- if (CTy->getScalarSizeInBits() < Ty->getScalarSizeInBits())
- return getSExt(C, Ty);
- if (CTy->getScalarSizeInBits() > Ty->getScalarSizeInBits())
- return getTrunc(C, Ty);
- return C;
-}
-
Constant *ConstantExpr::getPointerCast(Constant *S, Type *Ty) {
assert(S->getType()->isPtrOrPtrVectorTy() && "Invalid cast");
assert((Ty->isIntOrIntVectorTy() || Ty->isPtrOrPtrVectorTy()) &&
@@ -2048,18 +2023,6 @@ Constant *ConstantExpr::getPointerBitCastOrAddrSpaceCast(Constant *S,
return getBitCast(S, Ty);
}
-Constant *ConstantExpr::getIntegerCast(Constant *C, Type *Ty, bool isSigned) {
- assert(C->getType()->isIntOrIntVectorTy() &&
- Ty->isIntOrIntVectorTy() && "Invalid cast");
- unsigned SrcBits = C->getType()->getScalarSizeInBits();
- unsigned DstBits = Ty->getScalarSizeInBits();
- Instruction::CastOps opcode =
- (SrcBits == DstBits ? Instruction::BitCast :
- (SrcBits > DstBits ? Instruction::Trunc :
- (isSigned ? Instruction::SExt : Instruction::ZExt)));
- return getCast(opcode, C, Ty);
-}
-
Constant *ConstantExpr::getFPCast(Constant *C, Type *Ty) {
assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() &&
"Invalid cast");
@@ -2086,34 +2049,6 @@ Constant *ConstantExpr::getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) {
return getFoldedCast(Instruction::Trunc, C, Ty, OnlyIfReduced);
}
-Constant *ConstantExpr::getSExt(Constant *C, Type *Ty, bool OnlyIfReduced) {
-#ifndef NDEBUG
- bool fromVec = isa<VectorType>(C->getType());
- bool toVec = isa<VectorType>(Ty);
-#endif
- assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
- assert(C->getType()->isIntOrIntVectorTy() && "SExt operand must be integral");
- assert(Ty->isIntOrIntVectorTy() && "SExt produces only integer");
- assert(C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&&
- "SrcTy must be smaller than DestTy for SExt!");
-
- return getFoldedCast(Instruction::SExt, C, Ty, OnlyIfReduced);
-}
-
-Constant *ConstantExpr::getZExt(Constant *C, Type *Ty, bool OnlyIfReduced) {
-#ifndef NDEBUG
- bool fromVec = isa<VectorType>(C->getType());
- bool toVec = isa<VectorType>(Ty);
-#endif
- assert((fromVec == toVec) && "Cannot convert from scalar to/from vector");
- assert(C->getType()->isIntOrIntVectorTy() && "ZEXt operand must be integral");
- assert(Ty->isIntOrIntVectorTy() && "ZExt produces only integer");
- assert(C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&&
- "SrcTy must be smaller than DestTy for ZExt!");
-
- return getFoldedCast(Instruction::ZExt, C, Ty, OnlyIfReduced);
-}
-
Constant *ConstantExpr::getFPTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) {
#ifndef NDEBUG
bool fromVec = isa<VectorType>(C->getType());
@@ -2353,6 +2288,28 @@ bool ConstantExpr::isDesirableCastOp(unsigned Opcode) {
}
}
+bool ConstantExpr::isSupportedCastOp(unsigned Opcode) {
+ switch (Opcode) {
+ case Instruction::ZExt:
+ case Instruction::SExt:
+ return false;
+ case Instruction::Trunc:
+ case Instruction::FPTrunc:
+ case Instruction::FPExt:
+ case Instruction::UIToFP:
+ case Instruction::SIToFP:
+ case Instruction::FPToUI:
+ case Instruction::FPToSI:
+ case Instruction::PtrToInt:
+ case Instruction::IntToPtr:
+ case Instruction::BitCast:
+ case Instruction::AddrSpaceCast:
+ return true;
+ default:
+ llvm_unreachable("Argument must be cast opcode");
+ }
+}
+
Constant *ConstantExpr::getSizeOf(Type* Ty) {
// sizeof is implemented as: (i64) gep (Ty*)null, 1
// Note that a non-inbounds gep is used, as null isn't within any object.
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index d51ced879c4b154..076d1089582fe7e 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -1744,16 +1744,6 @@ LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
unwrap(ToType)));
}
-LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
- return wrap(ConstantExpr::getSExt(unwrap<Constant>(ConstantVal),
- unwrap(ToType)));
-}
-
-LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
- return wrap(ConstantExpr::getZExt(unwrap<Constant>(ConstantVal),
- unwrap(ToType)));
-}
-
LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
return wrap(ConstantExpr::getFPTrunc(unwrap<Constant>(ConstantVal),
unwrap(ToType)));
@@ -1805,18 +1795,6 @@ LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal,
unwrap(ToType)));
}
-LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal,
- LLVMTypeRef ToType) {
- return wrap(ConstantExpr::getZExtOrBitCast(unwrap<Constant>(ConstantVal),
- unwrap(ToType)));
-}
-
-LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal,
- LLVMTypeRef ToType) {
- return wrap(ConstantExpr::getSExtOrBitCast(unwrap<Constant>(ConstantVal),
- unwrap(ToType)));
-}
-
LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal,
LLVMTypeRef ToType) {
return wrap(ConstantExpr::getTruncOrBitCast(unwrap<Constant>(ConstantVal),
@@ -1829,12 +1807,6 @@ LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal,
unwrap(ToType)));
}
-LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType,
- LLVMBool isSigned) {
- return wrap(ConstantExpr::getIntegerCast(unwrap<Constant>(ConstantVal),
- unwrap(ToType), isSigned));
-}
-
LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType) {
return wrap(ConstantExpr::getFPCast(unwrap<Constant>(ConstantVal),
unwrap(ToType)));
diff --git a/llvm/test/Analysis/Lint/noop-cast-expr-no-pointer.ll b/llvm/test/Analysis/Lint/noop-cast-expr-no-pointer.ll
index d29fa0eb5475247..259b2c946c0bb23 100644
--- a/llvm/test/Analysis/Lint/noop-cast-expr-no-pointer.ll
+++ b/llvm/test/Analysis/Lint/noop-cast-expr-no-pointer.ll
@@ -7,14 +7,14 @@
define void @test1() {
entry:
- tail call void @f1(i16 zext (i1 icmp eq (ptr @g_2, ptr getelementptr inbounds ([3 x i32], ptr @g_1, i64 0, i64 1)) to i16))
+ tail call void @f1(i1 icmp eq (ptr @g_2, ptr getelementptr inbounds ([3 x i32], ptr @g_1, i64 0, i64 1)))
ret void
}
-declare void @f1(i16)
+declare void @f1(i1)
define void @test2() {
- tail call void inttoptr (i64 sext (i32 ptrtoint (ptr @f2 to i32) to i64) to ptr)()
+ tail call void inttoptr (i64 -1 to ptr)()
ret void
}
diff --git a/llvm/test/Analysis/ScalarEvolution/ptrtoint-constantexpr-loop.ll b/llvm/test/Analysis/ScalarEvolution/ptrtoint-constantexpr-loop.ll
index 31a6a6ec0023e58..802ebef82d9d394 100644
--- a/llvm/test/Analysis/ScalarEvolution/ptrtoint-constantexpr-loop.ll
+++ b/llvm/test/Analysis/ScalarEvolution/ptrtoint-constantexpr-loop.ll
@@ -281,7 +281,9 @@ bb10: ; preds = %bb7
define void @sext_to_i32(i32 %arg, i32 %arg6) {
; PTR64_IDX64-LABEL: 'sext_to_i32'
; PTR64_IDX64-NEXT: Classifying expressions for: @sext_to_i32
-; PTR64_IDX64-NEXT: %tmp = sub i32 %arg, sext (i16 ptrtoint (ptr @global to i16) to i32)
+; PTR64_IDX64-NEXT: %ext = sext i16 ptrtoint (ptr @global to i16) to i32
+; PTR64_IDX64-NEXT: --> (sext i16 (trunc i64 (ptrtoint ptr @global to i64) to i16) to i32) U: [-32768,32768) S: [-32768,32768) Exits: (sext i16 (trunc i64 (ptrtoint ptr @global to i64) to i16) to i32) LoopDispositions: { %bb7: Invariant }
+; PTR64_IDX64-NEXT: %tmp = sub i32 %arg, %ext
; PTR64_IDX64-NEXT: --> ((-1 * (sext i16 (trunc i64 (ptrtoint ptr @global to i64) to i16) to i32))<nsw> + %arg) U: full-set S: full-set Exits: ((-1 * (sext i16 (trunc i64 (ptrtoint ptr @global to i64) to i16) to i32))<nsw> + %arg) LoopDispositions: { %bb7: Invariant }
; PTR64_IDX64-NEXT: %tmp9 = select i1 %tmp8, i16 0, i16 1
; PTR64_IDX64-NEXT: --> %tmp9 U: [0,2) S: [0,2) Exits: <<Unknown>> LoopDispositions: { %bb7: Variant }
@@ -293,7 +295,9 @@ define void @sext_to_i32(i32 %arg, i32 %arg6) {
;
; PTR64_IDX32-LABEL: 'sext_to_i32'
; PTR64_IDX32-NEXT: Classifying expressions for: @sext_to_i32
-; PTR64_IDX32-NEXT: %tmp = sub i32 %arg, sext (i16 ptrtoint (ptr @global to i16) to i32)
+; PTR64_IDX32-NEXT: %ext = sext i16 ptrtoint (ptr @global to i16) to i32
+; PTR64_IDX32-NEXT: --> (sext i16 ptrtoint (ptr @global to i16) to i32) U: [-32768,32768) S: [-32768,32768) Exits: (sext i16 ptrtoint (ptr @global to i16) to i32) LoopDispositions: { %bb7: Invariant }
+; PTR64_IDX32-NEXT: %tmp = sub i32 %arg, %ext
; PTR64_IDX32-NEXT: --> ((-1 * (sext i16 ptrtoint (ptr @global to i16) to i32))<nsw> + %arg) U: full-set S: full-set Exits: ((-1 * (sext i16 ptrtoint (ptr @global to i16) to i32))<nsw> + %arg) LoopDispositions: { %bb7: Invariant }
; PTR64_IDX32-NEXT: %tmp9 = select i1 %tmp8, i16 0, i16 1
; PTR64_IDX32-NEXT: --> %tmp9 U: [0,2) S: [0,2) Exits: <<Unknown>> LoopDispositions: { %bb7: Variant }
@@ -305,7 +309,9 @@ define void @sext_to_i32(i32 %arg, i32 %arg6) {
;
; PTR16_IDX16-LABEL: 'sext_to_i32'
; PTR16_IDX16-NEXT: Classifying expressions for: @sext_to_i32
-; PTR16_IDX16-NEXT: %tmp = sub i32 %arg, sext (i16 ptrtoint (ptr @global to i16) to i32)
+; PTR16_IDX16-NEXT: %ext = sext i16 ptrtoint (ptr @global to i16) to i32
+; PTR16_IDX16-NEXT: --> (sext i16 (ptrtoint ptr @global to i16) to i32) U: [-32768,32768) S: [-32768,32768) Exits: (sext i16 (ptrtoint ptr @global to i16) to i32) LoopDispositions: { %bb7: Invariant }
+; PTR16_IDX16-NEXT: %tmp = sub i32 %arg, %ext
; PTR16_IDX16-NEXT: --> ((-1 * (sext i16 (ptrtoint ptr @global to i16) to i32))<nsw> + %arg) U: full-set S: full-set Exits: ((-1 * (sext i16 (ptrtoint ptr @global to i16) to i32))<nsw> + %arg) LoopDispositions: { %bb7: Invariant }
; PTR16_IDX16-NEXT: %tmp9 = select i1 %tmp8, i16 0, i16 1
; PTR16_IDX16-NEXT: --> %tmp9 U: [0,2) S: [0,2) Exits: <<Unknown>> LoopDispositions: { %bb7: Variant }
@@ -319,7 +325,8 @@ bb:
br label %bb7
bb7: ; preds = %bb7, %bb
- %tmp = sub i32 %arg, sext (i16 ptrtoint (ptr @global to i16) to i32)
+ %ext = sext i16 ptrtoint (ptr @global to i16) to i32
+ %tmp = sub i32 %arg, %ext
%tmp8 = icmp eq i32 %tmp, %arg6
%tmp9 = select i1 %tmp8, i16 0, i16 1
call void @use16(i16 %tmp9)
@@ -346,7 +353,8 @@ define i64 @sext_like_noop(i32 %n) {
; PTR64_IDX64-NEXT: Loop %for.body: symbolic max backedge-taken count is (-2 + (trunc i64 (ptrtoint ptr @sext_like_noop to i64) to i32))
; PTR64_IDX64-NEXT: Loop %for.body: Predicated backedge-taken count is (-2 + (trunc i64 (ptrtoint ptr @sext_like_noop to i64) to i32))
; PTR64_IDX64-NEXT: Predicates:
-; PTR64_IDX64: Loop %for.body: Trip multiple is 1
+; PTR64_IDX64-EMPTY:
+; PTR64_IDX64-NEXT: Loop %for.body: Trip multiple is 1
;
; PTR64_IDX32-LABEL: 'sext_like_noop'
; PTR64_IDX32-NEXT: Classifying expressions for: @sext_like_noop
@@ -364,7 +372,8 @@ define i64 @sext_like_noop(i32 %n) {
; PTR64_IDX32-NEXT: Loop %for.body: symbolic max backedge-taken count is (-2 + ptrtoint (ptr @sext_like_noop to i32))
; PTR64_IDX32-NEXT: Loop %for.body: Predicated backedge-taken count is (-2 + ptrtoint (ptr @sext_like_noop to i32))
; PTR64_IDX32-NEXT: Predicates:
-; PTR64_IDX32: Loop %for.body: Trip multiple is 1
+; PTR64_IDX32-EMPTY:
+; PTR64_IDX32-NEXT: Loop %for.body: Trip multiple is 1
;
; PTR16_IDX16-LABEL: 'sext_like_noop'
; PTR16_IDX16-NEXT: Classifying expressions for: @sext_like_noop
@@ -382,7 +391,8 @@ define i64 @sext_like_noop(i32 %n) {
; PTR16_IDX16-NEXT: Loop %for.body: symbolic max backedge-taken count is (-2 + (zext i16 (ptrtoint ptr @sext_like_noop to i16) to i32))<nsw>
; PTR16_IDX16-NEXT: Loop %for.body: Predicated backedge-taken count is (-2 + (zext i16 (ptrtoint ptr @sext_like_noop to i16) to i32))<nsw>
; PTR16_IDX16-NEXT: Predicates:
-; PTR16_IDX16: Loop %for.body: Trip multiple is 1
+; PTR16_IDX16-EMPTY:
+; PTR16_IDX16-NEXT: Loop %for.body: Trip multiple is 1
;
entry:
%cmp6 = icmp sgt i32 %n, 1
diff --git a/llvm/test/Assembler/2009-03-24-ZextConstantExpr.ll b/llvm/test/Assembler/2009-03-24-ZextConstantExpr.ll
deleted file mode 100644
index bd454204c94ab4f..000000000000000
--- a/llvm/test/Assembler/2009-03-24-ZextConstantExpr.ll
+++ /dev/null
@@ -1,12 +0,0 @@
-; RUN: llvm-as < %s | llvm-dis
-; RUN: verify-uselistorder %s
-; PR3876
- at gdtr = external global [0 x i8]
-
-define void @test() {
- call zeroext i1 @paging_map(i64 zext (i32 add (i32 ptrtoint (ptr @gdtr to i32), i32 -4096) to i64))
- ret void
-}
-
-declare zeroext i1 @paging_map(i64)
-
diff --git a/llvm/test/Bindings/OCaml/core.ml b/llvm/test/Bindings/OCaml/core.ml
index 1f6ece9532f1943..523d327f69eff5f 100644
--- a/llvm/test/Bindings/OCaml/core.ml
+++ b/llvm/test/Bindings/OCaml/core.ml
@@ -292,8 +292,6 @@ let test_constants () =
group "constant casts";
(* CHECK: const_trunc{{.*}}trunc
- * CHECK: const_sext{{.*}}sext
- * CHECK: const_zext{{.*}}zext
* CHECK: const_fptrunc{{.*}}fptrunc
* CHECK: const_fpext{{.*}}fpext
* CHECK: const_uitofp{{.*}}uitofp
@@ -303,13 +301,10 @@ let test_constants () =
* CHECK: const_ptrtoint{{.*}}ptrtoint
* CHECK: const_inttoptr{{.*}}inttoptr
* CHECK: const_bitcast{{.*}}bitcast
- * CHECK: const_intcast{{.*}}zext
*)
let i128_type = integer_type context 128 in
ignore (define_global "const_trunc" (const_trunc (const_add foldbomb five)
i8_type) m);
- ignore (define_global "const_sext" (const_sext foldbomb i128_type) m);
- ignore (define_global "const_zext" (const_zext foldbomb i128_type) m);
ignore (define_global "const_fptrunc" (const_fptrunc ffoldbomb float_type) m);
ignore (define_global "const_fpext" (const_fpext ffoldbomb fp128_type) m);
ignore (define_global "const_uitofp" (const_uitofp foldbomb double_type) m);
@@ -323,8 +318,6 @@ let test_constants () =
ignore (define_global "const_inttoptr" (const_inttoptr (const_add foldbomb five)
void_ptr) m);
ignore (define_global "const_bitcast" (const_bitcast ffoldbomb i64_type) m);
- ignore (define_global "const_intcast"
- (const_intcast foldbomb i128_type ~is_signed:false) m);
group "misc constants";
(* CHECK: const_size_of{{.*}}getelementptr{{.*}}null
diff --git a/llvm/test/CodeGen/AArch64/arm64-2012-05-09-LOADgot-bug.ll b/llvm/test/CodeGen/AArch64/arm64-2012-05-09-LOADgot-bug.ll
index f859d1f66e60dbe..761462be6b4b001 100644
--- a/llvm/test/CodeGen/AArch64/arm64-2012-05-09-LOADgot-bug.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-2012-05-09-LOADgot-bug.ll
@@ -4,7 +4,8 @@
define hidden void @t(ptr %addr) optsize ssp {
entry:
- store i64 zext (i32 ptrtoint (ptr @x to i32) to i64), ptr %addr, align 8
+ %ext = zext i32 ptrtoint (ptr @x to i32) to i64
+ store i64 %ext, ptr %addr, align 8
; CHECK: adrp x{{[0-9]+}}, _x at GOTPAGE
; CHECK: ldr x{{[0-9]+}}, [x{{[0-9]+}}, _x at GOTPAGEOFF]
; CHECK-NEXT: and x{{[0-9]+}}, x{{[0-9]+}}, #0xffffffff
diff --git a/llvm/test/CodeGen/AArch64/arm64-codegen-prepare-extload.ll b/llvm/test/CodeGen/AArch64/arm64-codegen-prepare-extload.ll
index f5b853faed8a2aa..23cbad0d15b4c16 100644
--- a/llvm/test/CodeGen/AArch64/arm64-codegen-prepare-extload.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-codegen-prepare-extload.ll
@@ -338,17 +338,19 @@ entry:
; OPTALL: [[LD:%[a-zA-Z_0-9-]+]] = load i16, ptr %addr
;
; OPT-NEXT: [[SEXT:%[a-zA-Z_0-9-]+]] = sext i16 [[LD]] to i32
-; OPT-NEXT: [[SEXT2:%[a-zA-Z_0-9-]+]] = sext i16 zext (i1 icmp ne (ptr getelementptr inbounds ([2 x i32], ptr @c, i64 0, i64 1), ptr @a) to i16) to i32
+; OPT-NEXT: [[SEXT2:%[a-zA-Z_0-9-]+]] = zext i1 icmp ne (ptr getelementptr inbounds ([2 x i32], ptr @c, i64 0, i64 1), ptr @a) to i32
; OPT-NEXT: [[RES:%[a-zA-Z_0-9-]+]] = add nuw nsw i32 [[SEXT]], [[SEXT2]]
;
-; DISABLE-NEXT: [[ADD:%[a-zA-Z_0-9-]+]] = add nuw nsw i16 [[LD]], zext (i1 icmp ne (ptr getelementptr inbounds ([2 x i32], ptr @c, i64 0, i64 1), ptr @a) to i16)
+; DISABLE-NEXT: [[EXT:%[a-zA-Z_0-9-]+]] = zext i1 icmp ne (ptr getelementptr inbounds ([2 x i32], ptr @c, i64 0, i64 1), ptr @a) to i16
+; DISABLE-NEXT: [[ADD:%[a-zA-Z_0-9-]+]] = add nuw nsw i16 [[LD]], [[EXT]]
; DISABLE-NEXT: [[RES:%[a-zA-Z_0-9-]+]] = sext i16 [[ADD]] to i32
;
; OPTALL-NEXT: ret i32 [[RES]]
define i32 @promotionOfArgEndsUpInValue(ptr %addr) {
entry:
%val = load i16, ptr %addr
- %add = add nuw nsw i16 %val, zext (i1 icmp ne (ptr getelementptr inbounds ([2 x i32], ptr @c, i64 0, i64 1), ptr @a) to i16)
+ %ext = zext i1 icmp ne (ptr getelementptr inbounds ([2 x i32], ptr @c, i64 0, i64 1), ptr @a) to i16
+ %add = add nuw nsw i16 %val, %ext
%conv3 = sext i16 %add to i32
ret i32 %conv3
}
diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-constantexpr.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-constantexpr.ll
index 609001df027c90d..5b09e5ba2b6f0e1 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-constantexpr.ll
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-constantexpr.ll
@@ -6,18 +6,15 @@
define i32 @test() {
; CHECK-LABEL: name: test
; CHECK: bb.1 (%ir-block.0):
- ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
- ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:_(p0) = G_INTTOPTR [[C]](s32)
; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @var
- ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[INTTOPTR]](p0), [[GV]]
- ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[ICMP]](s1)
- ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY [[ZEXT]](s32)
+ ; CHECK-NEXT: [[PTRTOINT:%[0-9]+]]:_(s32) = G_PTRTOINT [[GV]](p0)
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY [[PTRTOINT]](s32)
; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s32) = COPY [[COPY]](s32)
; CHECK-NEXT: [[COPY2:%[0-9]+]]:_(s32) = COPY [[COPY1]](s32)
; CHECK-NEXT: [[COPY3:%[0-9]+]]:_(s32) = COPY [[COPY2]](s32)
; CHECK-NEXT: $vgpr0 = COPY [[COPY3]](s32)
; CHECK-NEXT: SI_RETURN implicit $vgpr0
- ret i32 bitcast (<1 x i32> <i32 extractelement (<1 x i32> bitcast (i32 zext (i1 icmp eq (ptr @var, ptr inttoptr (i32 -1 to ptr)) to i32) to <1 x i32>), i64 0)> to i32)
+ ret i32 bitcast (<1 x i32> <i32 extractelement (<1 x i32> bitcast (i32 ptrtoint (ptr @var to i32) to <1 x i32>), i64 0)> to i32)
}
@a = external global [2 x i32], align 4
@@ -37,5 +34,6 @@ define i32 @test_fcmp_constexpr() {
; CHECK-NEXT: $vgpr0 = COPY [[ZEXT]](s32)
; CHECK-NEXT: SI_RETURN implicit $vgpr0
entry:
- ret i32 zext (i1 fcmp oeq (float uitofp (i1 icmp eq (ptr getelementptr inbounds ([2 x i32], ptr @a, i64 0, i64 1), ptr @var) to float), float 0.000000e+00) to i32)
+ %ext = zext i1 fcmp oeq (float uitofp (i1 icmp eq (ptr getelementptr inbounds ([2 x i32], ptr @a, i64 0, i64 1), ptr @var) to float), float 0.000000e+00) to i32
+ ret i32 %ext
}
diff --git a/llvm/test/CodeGen/ARM/2007-04-03-UndefinedSymbol.ll b/llvm/test/CodeGen/ARM/2007-04-03-UndefinedSymbol.ll
index c9acfcb65fe9357..c4236386b9ed255 100644
--- a/llvm/test/CodeGen/ARM/2007-04-03-UndefinedSymbol.ll
+++ b/llvm/test/CodeGen/ARM/2007-04-03-UndefinedSymbol.ll
@@ -26,53 +26,77 @@ entry:
%b.i29 = alloca %struct.B, align 4
%b.i1 = alloca %struct.B, align 4
%b.i = alloca %struct.B, align 4
- store i32 4, ptr %b.i
- %and1 = and i64 zext (i32 ptrtoint (ptr @_ZN1B1iEv to i32) to i64), 4294967296
+ store i32 4, ptr %b.i, align 4
+ %constexpr = ptrtoint ptr @_ZN1B1iEv to i32
+ %constexpr1 = zext i32 %constexpr to i64
+ %and1 = and i64 %constexpr1, 4294967296
%cmp1 = icmp eq i64 %and1, 0
- br i1 %cmp1, label %_Z3fooiM1BFvvE.exit, label %cond_true.i
+ br i1 %cmp1, label %phi.constexpr, label %cond_true.i
-cond_true.i:
- %ctg23.i = getelementptr i8, ptr %b.i, i32 ashr (i32 trunc (i64 lshr (i64 zext (i32 ptrtoint (ptr @_ZN1B1iEv to i32) to i64), i64 32) to i32), i32 1)
- %tmp15.i = load ptr, ptr %ctg23.i
- %ctg2.i = getelementptr i8, ptr %tmp15.i, i32 ptrtoint (ptr @_ZN1B1iEv to i32)
- %tmp22.i = load ptr, ptr %ctg2.i
+cond_true.i: ; preds = %entry
+ %ctg23.i = getelementptr i8, ptr %b.i, i32 0
+ %tmp15.i = load ptr, ptr %ctg23.i, align 8
+ %constexpr2 = ptrtoint ptr @_ZN1B1iEv to i32
+ %ctg2.i = getelementptr i8, ptr %tmp15.i, i32 %constexpr2
+ %tmp22.i = load ptr, ptr %ctg2.i, align 8
br label %_Z3fooiM1BFvvE.exit
-_Z3fooiM1BFvvE.exit:
- %iftmp.2.0.i = phi ptr [ %tmp22.i, %cond_true.i ], [ inttoptr (i32 ptrtoint (ptr @_ZN1B1iEv to i32) to ptr), %entry ]
- %ctg25.i = getelementptr i8, ptr %b.i, i32 ashr (i32 trunc (i64 lshr (i64 zext (i32 ptrtoint (ptr @_ZN1B1iEv to i32) to i64), i64 32) to i32), i32 1)
+phi.constexpr: ; preds = %entry
+ %constexpr3 = ptrtoint ptr @_ZN1B1iEv to i32
+ %constexpr4 = inttoptr i32 %constexpr3 to ptr
+ br label %_Z3fooiM1BFvvE.exit
+
+_Z3fooiM1BFvvE.exit: ; preds = %phi.constexpr, %cond_true.i
+ %iftmp.2.0.i = phi ptr [ %tmp22.i, %cond_true.i ], [ %constexpr4, %phi.constexpr ]
+ %ctg25.i = getelementptr i8, ptr %b.i, i32 0
call void %iftmp.2.0.i(ptr %ctg25.i)
- store i32 6, ptr %b.i29
- %and2 = and i64 zext (i32 ptrtoint (ptr @_ZN1B1iEv to i32) to i64), 4294967296
+ store i32 6, ptr %b.i29, align 4
+ %constexpr5 = ptrtoint ptr @_ZN1B1iEv to i32
+ %constexpr6 = zext i32 %constexpr5 to i64
+ %and2 = and i64 %constexpr6, 4294967296
%cmp2 = icmp eq i64 %and2, 0
- br i1 %cmp2, label %_Z3fooiM1BFvvE.exit56, label %cond_true.i46
+ br i1 %cmp2, label %phi.constexpr8, label %cond_true.i46
+
+cond_true.i46: ; preds = %_Z3fooiM1BFvvE.exit
+ %ctg23.i36 = getelementptr i8, ptr %b.i29, i32 0
+ %tmp15.i38 = load ptr, ptr %ctg23.i36, align 8
+ %constexpr7 = ptrtoint ptr @_ZN1B1jEv to i32
+ %ctg2.i42 = getelementptr i8, ptr %tmp15.i38, i32 %constexpr7
+ %tmp22.i44 = load ptr, ptr %ctg2.i42, align 8
+ br label %_Z3fooiM1BFvvE.exit56
-cond_true.i46:
- %ctg23.i36 = getelementptr i8, ptr %b.i29, i32 ashr (i32 trunc (i64 lshr (i64 zext (i32 ptrtoint (ptr @_ZN1B1jEv to i32) to i64), i64 32) to i32), i32 1)
- %tmp15.i38 = load ptr, ptr %ctg23.i36
- %ctg2.i42 = getelementptr i8, ptr %tmp15.i38, i32 ptrtoint (ptr @_ZN1B1jEv to i32)
- %tmp22.i44 = load ptr, ptr %ctg2.i42
+phi.constexpr8: ; preds = %_Z3fooiM1BFvvE.exit
+ %constexpr9 = ptrtoint ptr @_ZN1B1jEv to i32
+ %constexpr10 = inttoptr i32 %constexpr9 to ptr
br label %_Z3fooiM1BFvvE.exit56
-_Z3fooiM1BFvvE.exit56:
- %iftmp.2.0.i49 = phi ptr [ %tmp22.i44, %cond_true.i46 ], [ inttoptr (i32 ptrtoint (ptr @_ZN1B1jEv to i32) to ptr), %_Z3fooiM1BFvvE.exit ]
- %ctg25.i54 = getelementptr i8, ptr %b.i29, i32 ashr (i32 trunc (i64 lshr (i64 zext (i32 ptrtoint (ptr @_ZN1B1jEv to i32) to i64), i64 32) to i32), i32 1)
+_Z3fooiM1BFvvE.exit56: ; preds = %phi.constexpr8, %cond_true.i46
+ %iftmp.2.0.i49 = phi ptr [ %tmp22.i44, %cond_true.i46 ], [ %constexpr10, %phi.constexpr8 ]
+ %ctg25.i54 = getelementptr i8, ptr %b.i29, i32 0
call void %iftmp.2.0.i49(ptr %ctg25.i54)
- store i32 -1, ptr %b.i1
- %and3 = and i64 zext (i32 ptrtoint (ptr @_ZN1B1iEv to i32) to i64), 4294967296
+ store i32 -1, ptr %b.i1, align 4
+ %constexpr11 = ptrtoint ptr @_ZN1B1iEv to i32
+ %constexpr12 = zext i32 %constexpr11 to i64
+ %and3 = and i64 %constexpr12, 4294967296
%cmp3 = icmp eq i64 %and3, 0
- br i1 %cmp3, label %_Z3fooiM1BFvvE.exit28, label %cond_true.i18
+ br i1 %cmp3, label %phi.constexpr14, label %cond_true.i18
+
+cond_true.i18: ; preds = %_Z3fooiM1BFvvE.exit56
+ %ctg23.i8 = getelementptr i8, ptr %b.i1, i32 0
+ %tmp15.i10 = load ptr, ptr %ctg23.i8, align 8
+ %constexpr13 = ptrtoint ptr @_ZN1B1iEv to i32
+ %ctg2.i14 = getelementptr i8, ptr %tmp15.i10, i32 %constexpr13
+ %tmp22.i16 = load ptr, ptr %ctg2.i14, align 8
+ br label %_Z3fooiM1BFvvE.exit28
-cond_true.i18:
- %ctg23.i8 = getelementptr i8, ptr %b.i1, i32 ashr (i32 trunc (i64 lshr (i64 zext (i32 ptrtoint (ptr @_ZN1B1iEv to i32) to i64), i64 32) to i32), i32 1)
- %tmp15.i10 = load ptr, ptr %ctg23.i8
- %ctg2.i14 = getelementptr i8, ptr %tmp15.i10, i32 ptrtoint (ptr @_ZN1B1iEv to i32)
- %tmp22.i16 = load ptr, ptr %ctg2.i14
+phi.constexpr14: ; preds = %_Z3fooiM1BFvvE.exit56
+ %constexpr15 = ptrtoint ptr @_ZN1B1iEv to i32
+ %constexpr16 = inttoptr i32 %constexpr15 to ptr
br label %_Z3fooiM1BFvvE.exit28
-_Z3fooiM1BFvvE.exit28:
- %iftmp.2.0.i21 = phi ptr [ %tmp22.i16, %cond_true.i18 ], [ inttoptr (i32 ptrtoint (ptr @_ZN1B1iEv to i32) to ptr), %_Z3fooiM1BFvvE.exit56 ]
- %ctg25.i26 = getelementptr i8, ptr %b.i1, i32 ashr (i32 trunc (i64 lshr (i64 zext (i32 ptrtoint (ptr @_ZN1B1iEv to i32) to i64), i64 32) to i32), i32 1)
+_Z3fooiM1BFvvE.exit28: ; preds = %phi.constexpr14, %cond_true.i18
+ %iftmp.2.0.i21 = phi ptr [ %tmp22.i16, %cond_true.i18 ], [ %constexpr16, %phi.constexpr14 ]
+ %ctg25.i26 = getelementptr i8, ptr %b.i1, i32 0
call void %iftmp.2.0.i21(ptr %ctg25.i26)
ret i32 0
}
diff --git a/llvm/test/CodeGen/ARM/2012-01-23-PostRA-LICM.ll b/llvm/test/CodeGen/ARM/2012-01-23-PostRA-LICM.ll
index 667b61709893e34..2d196b2e6a0ec90 100644
--- a/llvm/test/CodeGen/ARM/2012-01-23-PostRA-LICM.ll
+++ b/llvm/test/CodeGen/ARM/2012-01-23-PostRA-LICM.ll
@@ -22,7 +22,15 @@ bb4: ; preds = %bb3
%tmp6 = and <4 x i32> %tmp5, <i32 8388607, i32 8388607, i32 8388607, i32 8388607>
%tmp7 = or <4 x i32> %tmp6, <i32 1065353216, i32 1065353216, i32 1065353216, i32 1065353216>
%tmp8 = bitcast <4 x i32> %tmp7 to <4 x float>
- %or = or i128 shl (i128 zext (i64 trunc (i128 lshr (i128 bitcast (<4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00> to i128), i128 64) to i64) to i128), i128 64), zext (i64 trunc (i128 bitcast (<4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00> to i128) to i64) to i128)
+ %constexpr = bitcast <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00> to i128
+ %constexpr1 = lshr i128 %constexpr, 64
+ %constexpr2 = trunc i128 %constexpr1 to i64
+ %constexpr3 = zext i64 %constexpr2 to i128
+ %constexpr4 = shl i128 %constexpr3, 64
+ %constexpr5 = bitcast <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00> to i128
+ %constexpr6 = trunc i128 %constexpr5 to i64
+ %constexpr7 = zext i64 %constexpr6 to i128
+ %or = or i128 %constexpr4, %constexpr7
%bc = bitcast i128 %or to <4 x float>
%tmp9 = fsub <4 x float> %tmp8, %bc
%tmp10 = fmul <4 x float> undef, %tmp9
@@ -31,14 +39,14 @@ bb4: ; preds = %bb3
%tmp13 = lshr i128 %tmp12, 64
%tmp14 = trunc i128 %tmp13 to i64
%tmp15 = insertvalue [2 x i64] undef, i64 %tmp14, 1
- %tmp16 = call <4 x float> @llvm.arm.neon.vrecpe.v4f32(<4 x float> %tmp11) nounwind
- %tmp17 = call <4 x float> @llvm.arm.neon.vrecps.v4f32(<4 x float> %tmp16, <4 x float> %tmp11) nounwind
+ %tmp16 = call <4 x float> @llvm.arm.neon.vrecpe.v4f32(<4 x float> %tmp11) #3
+ %tmp17 = call <4 x float> @llvm.arm.neon.vrecps.v4f32(<4 x float> %tmp16, <4 x float> %tmp11) #3
%tmp18 = fmul <4 x float> %tmp17, %tmp16
- %tmp19 = call <4 x float> @llvm.arm.neon.vrecps.v4f32(<4 x float> %tmp18, <4 x float> %tmp11) nounwind
+ %tmp19 = call <4 x float> @llvm.arm.neon.vrecps.v4f32(<4 x float> %tmp18, <4 x float> %tmp11) #3
%tmp20 = fmul <4 x float> %tmp19, %tmp18
%tmp21 = fmul <4 x float> %tmp20, zeroinitializer
- %tmp22 = call <4 x float> @llvm.arm.neon.vmins.v4f32(<4 x float> %tmp21, <4 x float> undef) nounwind
- call arm_aapcs_vfpcc void @bar(ptr null, ptr undef, ptr undef, [2 x i64] zeroinitializer) nounwind
+ %tmp22 = call <4 x float> @llvm.arm.neon.vmins.v4f32(<4 x float> %tmp21, <4 x float> undef) #3
+ call arm_aapcs_vfpcc void @bar(ptr null, ptr undef, ptr undef, [2 x i64] zeroinitializer) #3
%tmp23 = bitcast <4 x float> %tmp22 to i128
%tmp24 = trunc i128 %tmp23 to i64
%tmp25 = insertvalue [2 x i64] undef, i64 %tmp24, 0
@@ -49,16 +57,24 @@ bb4: ; preds = %bb3
%tmp30 = and <4 x i32> %tmp29, <i32 8388607, i32 8388607, i32 8388607, i32 8388607>
%tmp31 = or <4 x i32> %tmp30, <i32 1065353216, i32 1065353216, i32 1065353216, i32 1065353216>
%tmp32 = bitcast <4 x i32> %tmp31 to <4 x float>
- %or2 = or i128 shl (i128 zext (i64 trunc (i128 lshr (i128 bitcast (<4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00> to i128), i128 64) to i64) to i128), i128 64), zext (i64 trunc (i128 bitcast (<4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00> to i128) to i64) to i128)
+ %constexpr8 = bitcast <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00> to i128
+ %constexpr9 = lshr i128 %constexpr8, 64
+ %constexpr10 = trunc i128 %constexpr9 to i64
+ %constexpr11 = zext i64 %constexpr10 to i128
+ %constexpr12 = shl i128 %constexpr11, 64
+ %constexpr13 = bitcast <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00> to i128
+ %constexpr14 = trunc i128 %constexpr13 to i64
+ %constexpr15 = zext i64 %constexpr14 to i128
+ %or2 = or i128 %constexpr12, %constexpr15
%bc2 = bitcast i128 %or2 to <4 x float>
%tmp33 = fsub <4 x float> %tmp32, %bc2
- %tmp34 = call <4 x float> @llvm.arm.neon.vrecps.v4f32(<4 x float> undef, <4 x float> %tmp28) nounwind
+ %tmp34 = call <4 x float> @llvm.arm.neon.vrecps.v4f32(<4 x float> undef, <4 x float> %tmp28) #3
%tmp35 = fmul <4 x float> %tmp34, undef
%tmp36 = fmul <4 x float> %tmp35, undef
- %tmp37 = call arm_aapcs_vfpcc ptr undef(ptr undef) nounwind
+ %tmp37 = call arm_aapcs_vfpcc ptr undef(ptr undef) #3
%tmp38 = load float, ptr undef, align 4
%tmp39 = insertelement <2 x float> undef, float %tmp38, i32 0
- %tmp40 = call arm_aapcs_vfpcc ptr undef(ptr undef) nounwind
+ %tmp40 = call arm_aapcs_vfpcc ptr undef(ptr undef) #3
%tmp41 = load float, ptr undef, align 4
%tmp42 = insertelement <4 x float> undef, float %tmp41, i32 3
%tmp43 = shufflevector <2 x float> %tmp39, <2 x float> undef, <4 x i32> zeroinitializer
@@ -67,25 +83,25 @@ bb4: ; preds = %bb3
%tmp46 = fsub <4 x float> %tmp45, undef
%tmp47 = fmul <4 x float> %tmp46, %tmp36
%tmp48 = fadd <4 x float> undef, %tmp47
- %tmp49 = call arm_aapcs_vfpcc ptr undef(ptr undef) nounwind
+ %tmp49 = call arm_aapcs_vfpcc ptr undef(ptr undef) #3
%tmp50 = load float, ptr undef, align 4
%tmp51 = insertelement <4 x float> undef, float %tmp50, i32 3
- %tmp52 = call arm_aapcs_vfpcc ptr null(ptr undef) nounwind
+ %tmp52 = call arm_aapcs_vfpcc ptr null(ptr undef) #3
%tmp54 = load float, ptr %tmp52, align 4
%tmp55 = insertelement <4 x float> undef, float %tmp54, i32 3
%tmp56 = fsub <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, %tmp22
- %tmp57 = call <4 x float> @llvm.arm.neon.vmins.v4f32(<4 x float> %tmp56, <4 x float> %tmp55) nounwind
+ %tmp57 = call <4 x float> @llvm.arm.neon.vmins.v4f32(<4 x float> %tmp56, <4 x float> %tmp55) #3
%tmp58 = fmul <4 x float> undef, %tmp57
%tmp59 = fsub <4 x float> %tmp51, %tmp48
%tmp60 = fsub <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, %tmp58
%tmp61 = fmul <4 x float> %tmp59, %tmp60
%tmp62 = fadd <4 x float> %tmp48, %tmp61
- call arm_aapcs_vfpcc void @baz(ptr undef, ptr undef, [2 x i64] %tmp26, ptr undef)
+ call arm_aapcs_vfpcc void @baz(ptr undef, ptr undef, [2 x i64] %tmp26, ptr undef)
%tmp63 = bitcast <4 x float> %tmp62 to i128
%tmp64 = lshr i128 %tmp63, 64
%tmp65 = trunc i128 %tmp64 to i64
%tmp66 = insertvalue [2 x i64] zeroinitializer, i64 %tmp65, 1
- call arm_aapcs_vfpcc void @quux(ptr undef, ptr undef, [2 x i64] undef, ptr undef, [2 x i64] %tmp66, ptr undef, ptr undef, [2 x i64] %tmp26, [2 x i64] %tmp15, ptr undef)
+ call arm_aapcs_vfpcc void @quux(ptr undef, ptr undef, [2 x i64] undef, ptr undef, [2 x i64] %tmp66, ptr undef, ptr undef, [2 x i64] %tmp26, [2 x i64] %tmp15, ptr undef)
br label %bb3
bb67: ; preds = %bb3
diff --git a/llvm/test/CodeGen/ARM/2018-02-13-PR36079.ll b/llvm/test/CodeGen/ARM/2018-02-13-PR36079.ll
index da6aa117ef4136b..6a779127860d7d4 100644
--- a/llvm/test/CodeGen/ARM/2018-02-13-PR36079.ll
+++ b/llvm/test/CodeGen/ARM/2018-02-13-PR36079.ll
@@ -6,11 +6,20 @@
define void @foo() local_unnamed_addr nounwind norecurse {
entry:
%0 = load <4 x i32>, ptr @c, align 4
- %1 = and <4 x i32> %0,
- <i32 1,
- i32 zext (i1 icmp ne (ptr getelementptr inbounds ([4 x i32], ptr @c, i32 0, i32 1), ptr @d) to i32),
- i32 zext (i1 icmp ne (ptr getelementptr inbounds ([4 x i32], ptr @c, i32 0, i32 2), ptr @d) to i32),
- i32 zext (i1 icmp ne (ptr getelementptr inbounds ([4 x i32], ptr @c, i32 0, i32 3), ptr @d) to i32)>
+ %constexpr = getelementptr inbounds [4 x i32], ptr @c, i32 0, i32 1
+ %constexpr1 = icmp ne ptr %constexpr, @d
+ %constexpr2 = zext i1 %constexpr1 to i32
+ %constexpr3 = getelementptr inbounds [4 x i32], ptr @c, i32 0, i32 2
+ %constexpr4 = icmp ne ptr %constexpr3, @d
+ %constexpr5 = zext i1 %constexpr4 to i32
+ %constexpr6 = getelementptr inbounds [4 x i32], ptr @c, i32 0, i32 3
+ %constexpr7 = icmp ne ptr %constexpr6, @d
+ %constexpr8 = zext i1 %constexpr7 to i32
+ %constexpr.ins = insertelement <4 x i32> poison, i32 1, i32 0
+ %constexpr.ins9 = insertelement <4 x i32> %constexpr.ins, i32 %constexpr2, i32 1
+ %constexpr.ins10 = insertelement <4 x i32> %constexpr.ins9, i32 %constexpr5, i32 2
+ %constexpr.ins11 = insertelement <4 x i32> %constexpr.ins10, i32 %constexpr8, i32 3
+ %1 = and <4 x i32> %0, %constexpr.ins11
store <4 x i32> %1, ptr @c, align 4
ret void
; CHECK-NOT: mvnne
diff --git a/llvm/test/CodeGen/Hexagon/opt-addr-mode-subreg-use.ll b/llvm/test/CodeGen/Hexagon/opt-addr-mode-subreg-use.ll
index 9b098d08f536214..c51bd911bfffee6 100644
--- a/llvm/test/CodeGen/Hexagon/opt-addr-mode-subreg-use.ll
+++ b/llvm/test/CodeGen/Hexagon/opt-addr-mode-subreg-use.ll
@@ -58,27 +58,33 @@ b2: ; preds = %b1
%v6 = ptrtoint ptr %v0 to i32
%v7 = zext i32 %v6 to i64
%v8 = shl nuw i64 %v7, 32
- %v9 = or i64 %v8, zext (i32 ptrtoint (ptr @f2 to i32) to i64)
+ %f2.ext = zext i32 ptrtoint (ptr @f2 to i32) to i64
+ %v9 = or i64 %v8, %f2.ext
%v10 = ptrtoint ptr %v4 to i32
%v11 = zext i32 %v10 to i64
%v12 = shl nuw i64 %v11, 32
- %v13 = or i64 %v12, zext (i32 ptrtoint (ptr @f5 to i32) to i64)
+ %f5.ext = zext i32 ptrtoint (ptr @f5 to i32) to i64
+ %v13 = or i64 %v12, %f5.ext
%v14 = ptrtoint ptr %v5 to i32
%v15 = zext i32 %v14 to i64
%v16 = shl nuw i64 %v15, 32
- %v17 = or i64 %v16, zext (i32 ptrtoint (ptr @f6 to i32) to i64)
+ %f6.ext = zext i32 ptrtoint (ptr @f6 to i32) to i64
+ %v17 = or i64 %v16, %f6.ext
%v18 = ptrtoint ptr %v1 to i32
%v19 = zext i32 %v18 to i64
%v20 = shl nuw i64 %v19, 32
- %v21 = or i64 %v20, zext (i32 ptrtoint (ptr @f3 to i32) to i64)
+ %f3.ext = zext i32 ptrtoint (ptr @f3 to i32) to i64
+ %v21 = or i64 %v20, %f3.ext
%v22 = ptrtoint ptr %v2 to i32
%v23 = zext i32 %v22 to i64
%v24 = shl nuw i64 %v23, 32
- %v25 = or i64 %v24, zext (i32 ptrtoint (ptr @f4 to i32) to i64)
+ %f4.ext = zext i32 ptrtoint (ptr @f4 to i32) to i64
+ %v25 = or i64 %v24, %f4.ext
%v26 = ptrtoint ptr %v3 to i32
%v27 = zext i32 %v26 to i64
%v28 = shl nuw i64 %v27, 32
- %v29 = or i64 %v28, zext (i32 ptrtoint (ptr @f7 to i32) to i64)
+ %f7.ext = zext i32 ptrtoint (ptr @f7 to i32) to i64
+ %v29 = or i64 %v28, %f7.ext
%v30 = call ptr @f9(ptr nonnull null) #1
br i1 undef, label %b5, label %b4
diff --git a/llvm/test/CodeGen/Hexagon/packetize-l2fetch.ll b/llvm/test/CodeGen/Hexagon/packetize-l2fetch.ll
index 9eeca4f252a65ff..77d8351b2eed2be 100644
--- a/llvm/test/CodeGen/Hexagon/packetize-l2fetch.ll
+++ b/llvm/test/CodeGen/Hexagon/packetize-l2fetch.ll
@@ -16,7 +16,8 @@ target triple = "hexagon"
; Function Attrs: nounwind
define void @f0() local_unnamed_addr #0 {
b0:
- %and = and i32 sext (i8 ptrtoint (ptr getelementptr inbounds ([32768 x i8], ptr @g0, i32 0, i32 10000) to i8) to i32), -65536
+ %ext = sext i8 ptrtoint (ptr getelementptr inbounds ([32768 x i8], ptr @g0, i32 0, i32 10000) to i8) to i32
+ %and = and i32 %ext, -65536
%ptr = inttoptr i32 %and to ptr
store ptr %ptr, ptr getelementptr inbounds ([15 x ptr], ptr @g1, i32 0, i32 1), align 4
store ptr %ptr, ptr getelementptr inbounds ([15 x ptr], ptr @g1, i32 0, i32 6), align 8
diff --git a/llvm/test/CodeGen/PowerPC/ext-bool-trunc-repl.ll b/llvm/test/CodeGen/PowerPC/ext-bool-trunc-repl.ll
index a64354222fa7584..3304c3a9a25f0c7 100644
--- a/llvm/test/CodeGen/PowerPC/ext-bool-trunc-repl.ll
+++ b/llvm/test/CodeGen/PowerPC/ext-bool-trunc-repl.ll
@@ -8,7 +8,6 @@ target triple = "powerpc64le-unknown-linux-gnu"
; Function Attrs: norecurse nounwind
define void @fn2() #0 {
; CHECK-LABEL: @fn2
-
br i1 undef, label %1, label %10
1: ; preds = %0
@@ -22,16 +21,27 @@ define void @fn2() #0 {
4: ; preds = %4, %3
%5 = phi i64 [ %6, %4 ], [ undef, %3 ]
- %constexpr = select i1 icmp slt (i16 zext (i1 icmp eq (ptr getelementptr inbounds ([2 x i32], ptr @d, i64 0, i64 1), ptr @c) to i16), i16 0), i32 zext (i1 icmp eq (ptr getelementptr inbounds ([2 x i32], ptr @d, i64 0, i64 1), ptr @c) to i32), i32 lshr (i32 zext (i1 icmp eq (ptr getelementptr inbounds ([2 x i32], ptr @d, i64 0, i64 1), ptr @c) to i32), i32 6)
- %constexpr1 = sext i32 %constexpr to i64
- %constexpr2 = and i64 %constexpr1, %constexpr1
- %constexpr3 = and i64 %constexpr2, %constexpr1
- %constexpr4 = and i64 %constexpr3, %constexpr1
- %constexpr5 = and i64 %constexpr4, %constexpr1
- %constexpr6 = and i64 %constexpr5, %constexpr1
- %constexpr7 = and i64 %constexpr6, %constexpr1
- %constexpr8 = and i64 %constexpr7, %constexpr1
- %6 = and i64 %5, %constexpr8
+ %constexpr = getelementptr inbounds [2 x i32], ptr @d, i64 0, i64 1
+ %constexpr1 = icmp eq ptr %constexpr, @c
+ %constexpr2 = zext i1 %constexpr1 to i32
+ %constexpr3 = getelementptr inbounds [2 x i32], ptr @d, i64 0, i64 1
+ %constexpr4 = icmp eq ptr %constexpr3, @c
+ %constexpr5 = zext i1 %constexpr4 to i32
+ %constexpr6 = lshr i32 %constexpr5, 6
+ %constexpr7 = getelementptr inbounds [2 x i32], ptr @d, i64 0, i64 1
+ %constexpr8 = icmp eq ptr %constexpr7, @c
+ %constexpr9 = zext i1 %constexpr8 to i16
+ %constexpr10 = icmp slt i16 %constexpr9, 0
+ %constexpr11 = select i1 %constexpr10, i32 %constexpr2, i32 %constexpr6
+ %constexpr112 = sext i32 %constexpr11 to i64
+ %constexpr213 = and i64 %constexpr112, %constexpr112
+ %constexpr314 = and i64 %constexpr213, %constexpr112
+ %constexpr415 = and i64 %constexpr314, %constexpr112
+ %constexpr516 = and i64 %constexpr415, %constexpr112
+ %constexpr617 = and i64 %constexpr516, %constexpr112
+ %constexpr718 = and i64 %constexpr617, %constexpr112
+ %constexpr819 = and i64 %constexpr718, %constexpr112
+ %6 = and i64 %5, %constexpr819
%7 = icmp slt i32 undef, 6
br i1 %7, label %4, label %8
diff --git a/llvm/test/CodeGen/WebAssembly/fast-isel-noreg.ll b/llvm/test/CodeGen/WebAssembly/fast-isel-noreg.ll
index 56e599a7132e845..574ed1a11f43083 100644
--- a/llvm/test/CodeGen/WebAssembly/fast-isel-noreg.ll
+++ b/llvm/test/CodeGen/WebAssembly/fast-isel-noreg.ll
@@ -8,7 +8,8 @@ target triple = "wasm32-unknown-unknown"
; CHECK: i32.const $push0=, 0
define hidden i32 @a() #0 {
entry:
- ret i32 zext (i1 icmp eq (ptr inttoptr (i32 10 to ptr), ptr null) to i32)
+ %ext = zext i1 icmp eq (ptr inttoptr (i32 10 to ptr), ptr null) to i32
+ ret i32 %ext
}
; CHECK: i32.const $push0=, 1
@@ -27,7 +28,8 @@ b:
; CHECK: i32.store 0($pop1), $pop2
define hidden i32 @c() #0 {
entry:
- store i32 zext (i1 icmp eq (ptr inttoptr (i32 10 to ptr), ptr null) to i32), ptr inttoptr (i32 0 to ptr)
+ %ext = zext i1 icmp eq (ptr inttoptr (i32 10 to ptr), ptr null) to i32
+ store i32 %ext, ptr inttoptr (i32 0 to ptr)
ret i32 0
}
diff --git a/llvm/test/CodeGen/X86/2008-09-19-RegAllocBug.ll b/llvm/test/CodeGen/X86/2008-09-19-RegAllocBug.ll
index f027f3aa77d787f..bd85296d8ced7f0 100644
--- a/llvm/test/CodeGen/X86/2008-09-19-RegAllocBug.ll
+++ b/llvm/test/CodeGen/X86/2008-09-19-RegAllocBug.ll
@@ -9,7 +9,9 @@ entry:
%1 = trunc i32 %0 to i8 ; <i8> [#uses=1]
%2 = sub i8 1, %1 ; <i8> [#uses=1]
%3 = sext i8 %2 to i32 ; <i32> [#uses=1]
- %s = select i1 icmp ne (i8 zext (i1 icmp ugt (i32 ptrtoint (ptr @func_4 to i32), i32 3) to i8), i8 0), i32 0, i32 ptrtoint (ptr @func_4 to i32)
+ %ext = zext i1 icmp ugt (i32 ptrtoint (ptr @func_4 to i32), i32 3) to i8
+ %c = icmp ne i8 %ext, 0
+ %s = select i1 %c, i32 0, i32 ptrtoint (ptr @func_4 to i32)
%ashr = ashr i32 %3, %s
%urem = urem i32 %0, %ashr
%cmp = icmp eq i32 %urem, 0
diff --git a/llvm/test/CodeGen/X86/2012-03-20-LargeConstantExpr.ll b/llvm/test/CodeGen/X86/2012-03-20-LargeConstantExpr.ll
deleted file mode 100644
index ce566ea09b70b61..000000000000000
--- a/llvm/test/CodeGen/X86/2012-03-20-LargeConstantExpr.ll
+++ /dev/null
@@ -1,17 +0,0 @@
-; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
-; <rdar://problem/11070338>
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
-target triple = "x86_64-apple-macosx10.8.0"
-
-; CHECK: _.memset_pattern:
-; CHECK-NEXT: .quad 4575657222473777152
-; CHECK-NEXT: .quad 4575657222473777152
-
- at .memset_pattern = internal unnamed_addr constant i128 add (i128 zext (i64 bitcast (<2 x float> <float 1.000000e+00, float 1.000000e+00> to i64) to i128), i128 shl (i128 zext (i64 bitcast (<2 x float> <float 1.000000e+00, float 1.000000e+00> to i64) to i128), i128 64)), align 16
-
-define void @foo(ptr %a, i64 %b) {
- call void @memset_pattern16(ptr %a, ptr @.memset_pattern, i64 %b)
- ret void
-}
-
-declare void @memset_pattern16(ptr, ptr, i64)
diff --git a/llvm/test/CodeGen/X86/absolute-constant.ll b/llvm/test/CodeGen/X86/absolute-constant.ll
index 209e9f872612d02..5cd9bd8f56e6665 100644
--- a/llvm/test/CodeGen/X86/absolute-constant.ll
+++ b/llvm/test/CodeGen/X86/absolute-constant.ll
@@ -30,7 +30,8 @@ define void @bar(ptr %x) {
entry:
%0 = load i8, ptr %x, align 1
%conv = sext i8 %0 to i32
- %and = and i32 %conv, sext (i8 ptrtoint (ptr @foo to i8) to i32)
+ %ext = sext i8 ptrtoint (ptr @foo to i8) to i32
+ %and = and i32 %conv, %ext
%tobool = icmp eq i32 %and, 0
br i1 %tobool, label %if.end, label %if.then
diff --git a/llvm/test/CodeGen/X86/absolute-rotate.ll b/llvm/test/CodeGen/X86/absolute-rotate.ll
index f1b9558758bce70..2b754332c7095d8 100644
--- a/llvm/test/CodeGen/X86/absolute-rotate.ll
+++ b/llvm/test/CodeGen/X86/absolute-rotate.ll
@@ -9,8 +9,10 @@ target triple = "x86_64-unknown-linux-gnu"
declare void @f()
define void @foo(i64 %val) {
- %shr = lshr i64 %val, zext (i8 ptrtoint (ptr @align to i8) to i64)
- %shl = shl i64 %val, zext (i8 sub (i8 64, i8 ptrtoint (ptr @align to i8)) to i64)
+ %ext1 = zext i8 ptrtoint (ptr @align to i8) to i64
+ %shr = lshr i64 %val, %ext1
+ %ext2 = zext i8 sub (i8 64, i8 ptrtoint (ptr @align to i8)) to i64
+ %shl = shl i64 %val, %ext2
; CHECK: rorq $align at ABS8, %rdi
%ror = or i64 %shr, %shl
%cmp = icmp ult i64 %ror, 109
@@ -25,8 +27,10 @@ f:
}
define void @bar(i64 %val) {
- %shr = shl i64 %val, zext (i8 ptrtoint (ptr @align to i8) to i64)
- %shl = lshr i64 %val, zext (i8 sub (i8 64, i8 ptrtoint (ptr @align to i8)) to i64)
+ %ext1 = zext i8 ptrtoint (ptr @align to i8) to i64
+ %shr = shl i64 %val, %ext1
+ %ext2 = zext i8 sub (i8 64, i8 ptrtoint (ptr @align to i8)) to i64
+ %shl = lshr i64 %val, %ext2
; CHECK: rolq $align at ABS8, %rdi
%rol = or i64 %shr, %shl
%cmp = icmp ult i64 %rol, 109
diff --git a/llvm/test/CodeGen/X86/address-type-promotion-constantexpr.ll b/llvm/test/CodeGen/X86/address-type-promotion-constantexpr.ll
index 9b6b482bc9cf917..70ee93d4010612a 100644
--- a/llvm/test/CodeGen/X86/address-type-promotion-constantexpr.ll
+++ b/llvm/test/CodeGen/X86/address-type-promotion-constantexpr.ll
@@ -10,7 +10,8 @@
; CHECK: xor %eax, %eax
define i32 @main() {
entry:
- %or = or i8 zext (i1 icmp eq (ptr getelementptr inbounds ([2 x i32], ptr @c, i64 0, i64 1), ptr @a) to i8), 1
+ %ext = zext i1 icmp eq (ptr getelementptr inbounds ([2 x i32], ptr @c, i64 0, i64 1), ptr @a) to i8
+ %or = or i8 %ext, 1
%sext = sext i8 %or to i64
%gep = getelementptr [2 x i8], ptr @b, i64 0, i64 %sext
%foo = load i8, ptr %gep, align 1
diff --git a/llvm/test/CodeGen/X86/codegen-prepare-extload.ll b/llvm/test/CodeGen/X86/codegen-prepare-extload.ll
index 676322cd0014f9a..ff0ac5bfd6a7dae 100644
--- a/llvm/test/CodeGen/X86/codegen-prepare-extload.ll
+++ b/llvm/test/CodeGen/X86/codegen-prepare-extload.ll
@@ -546,21 +546,23 @@ define i32 @promotionOfArgEndsUpInValue(ptr %addr) {
; OPT-NEXT: entry:
; OPT-NEXT: [[VAL:%.*]] = load i16, ptr [[ADDR]], align 2
; OPT-NEXT: [[CONV3:%.*]] = sext i16 [[VAL]] to i32
-; OPT-NEXT: [[PROMOTED:%.*]] = sext i16 zext (i1 icmp ne (ptr getelementptr inbounds ([2 x i32], ptr @c, i64 0, i64 1), ptr @a) to i16) to i32
-; OPT-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[CONV3]], [[PROMOTED]]
+; OPT-NEXT: [[PROMOTED1:%.*]] = zext i1 icmp ne (ptr getelementptr inbounds ([2 x i32], ptr @c, i64 0, i64 1), ptr @a) to i32
+; OPT-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[CONV3]], [[PROMOTED1]]
; OPT-NEXT: ret i32 [[ADD]]
;
; DISABLE-LABEL: define i32 @promotionOfArgEndsUpInValue(
; DISABLE-SAME: ptr [[ADDR:%.*]]) {
; DISABLE-NEXT: entry:
; DISABLE-NEXT: [[VAL:%.*]] = load i16, ptr [[ADDR]], align 2
-; DISABLE-NEXT: [[ADD:%.*]] = add nuw nsw i16 [[VAL]], zext (i1 icmp ne (ptr getelementptr inbounds ([2 x i32], ptr @c, i64 0, i64 1), ptr @a) to i16)
+; DISABLE-NEXT: [[EXT:%.*]] = zext i1 icmp ne (ptr getelementptr inbounds ([2 x i32], ptr @c, i64 0, i64 1), ptr @a) to i16
+; DISABLE-NEXT: [[ADD:%.*]] = add nuw nsw i16 [[VAL]], [[EXT]]
; DISABLE-NEXT: [[CONV3:%.*]] = sext i16 [[ADD]] to i32
; DISABLE-NEXT: ret i32 [[CONV3]]
;
entry:
%val = load i16, ptr %addr
- %add = add nuw nsw i16 %val, zext (i1 icmp ne (ptr getelementptr inbounds ([2 x i32], ptr @c, i64 0, i64 1), ptr @a) to i16)
+ %ext = zext i1 icmp ne (ptr getelementptr inbounds ([2 x i32], ptr @c, i64 0, i64 1), ptr @a) to i16
+ %add = add nuw nsw i16 %val, %ext
%conv3 = sext i16 %add to i32
ret i32 %conv3
}
diff --git a/llvm/test/CodeGen/X86/fast-isel-expect.ll b/llvm/test/CodeGen/X86/fast-isel-expect.ll
index 9eceafde3f7ce09..37dd72ee3ed6ad5 100644
--- a/llvm/test/CodeGen/X86/fast-isel-expect.ll
+++ b/llvm/test/CodeGen/X86/fast-isel-expect.ll
@@ -9,7 +9,8 @@ declare i64 @llvm.expect.i64(i64, i64)
define void @test() {
; CHECK: movl $glbl
- %tmp = call i64 @llvm.expect.i64(i64 zext (i1 icmp eq (ptr @glbl, ptr null) to i64), i64 0)
+ %ext = zext i1 icmp eq (ptr @glbl, ptr null) to i64
+ %tmp = call i64 @llvm.expect.i64(i64 %ext, i64 0)
%tmp2 = icmp ne i64 %tmp, 0
br i1 %tmp2, label %bb1, label %bb2
diff --git a/llvm/test/Feature/constexpr.ll b/llvm/test/Feature/constexpr.ll
index 14040cf03d5cb0c..4391f96422d67c0 100644
--- a/llvm/test/Feature/constexpr.ll
+++ b/llvm/test/Feature/constexpr.ll
@@ -42,7 +42,7 @@
@char8a = global i32* bitcast (i8* getelementptr([11x i8], [11x i8]* @somestr, i64 0, i64 8) to i32*)
;; getelementptr containing casts
- at char8b = global i8* getelementptr([11x i8], [11x i8]* @somestr, i64 sext (i8 0 to i64), i64 sext (i8 8 to i64))
+ at char8b = global i8* getelementptr([11x i8], [11x i8]* @somestr, i64 trunc (i128 0 to i64), i64 trunc (i128 8 to i64))
;;-------------------------------------------------------
;; TODO: Test constant getelementpr expressions for structures
diff --git a/llvm/test/Feature/newcasts.ll b/llvm/test/Feature/newcasts.ll
index e59c22581a66679..828b12063e885c2 100644
--- a/llvm/test/Feature/newcasts.ll
+++ b/llvm/test/Feature/newcasts.ll
@@ -25,12 +25,3 @@ define void @"NewCasts" (i16 %x) {
%z = addrspacecast <4 x ptr> %s to <4 x ptr addrspace(2)>
ret void
}
-
-
-define i16 @"ZExtConst" () {
- ret i16 trunc ( i32 zext ( i16 42 to i32) to i16 )
-}
-
-define i16 @"SExtConst" () {
- ret i16 trunc (i32 sext (i16 42 to i32) to i16 )
-}
diff --git a/llvm/test/Feature/vector-cast-constant-exprs.ll b/llvm/test/Feature/vector-cast-constant-exprs.ll
index 992987ca04cdc99..c81b7aace7fc0fc 100644
--- a/llvm/test/Feature/vector-cast-constant-exprs.ll
+++ b/llvm/test/Feature/vector-cast-constant-exprs.ll
@@ -8,12 +8,6 @@ define <2 x float> @ga() {
define <2 x double> @gb() {
ret <2 x double> fpext (<2 x float><float 2.0, float 8.0> to <2 x double>)
}
-define <2 x i64> @gd() {
- ret <2 x i64> zext (<2 x i32><i32 3, i32 4> to <2 x i64>)
-}
-define <2 x i64> @ge() {
- ret <2 x i64> sext (<2 x i32><i32 3, i32 4> to <2 x i64>)
-}
define <2 x i32> @gf() {
ret <2 x i32> trunc (<2 x i64><i64 3, i64 4> to <2 x i32>)
}
diff --git a/llvm/test/Integer/constexpr_bt.ll b/llvm/test/Integer/constexpr_bt.ll
index 0c60d728055c8d4..dc56bc0587a6080 100644
--- a/llvm/test/Integer/constexpr_bt.ll
+++ b/llvm/test/Integer/constexpr_bt.ll
@@ -44,7 +44,7 @@
@char8a = global i33* bitcast (i8* getelementptr([11x i8], [11x i8]* @somestr, i64 0, i64 8) to i33*)
;; getelementptr containing casts
- at char8b = global i8* getelementptr([11x i8], [11x i8]* @somestr, i64 sext (i8 0 to i64), i64 sext (i8 8 to i64))
+ at char8b = global i8* getelementptr([11x i8], [11x i8]* @somestr, i64 trunc (i128 0 to i64), i64 trunc (i128 8 to i64))
;;-------------------------------------------------------
;; TODO: Test constant getelementpr expressions for structures
diff --git a/llvm/test/Integer/newcasts_bt.ll b/llvm/test/Integer/newcasts_bt.ll
index e2eee4f7f12e511..741073fdda7855f 100644
--- a/llvm/test/Integer/newcasts_bt.ll
+++ b/llvm/test/Integer/newcasts_bt.ll
@@ -17,12 +17,3 @@ define void @"NewCasts" (i17 %x) {
%m = ptrtoint i32* %l to i64
ret void
}
-
-
-define i17 @"ZExtConst" () {
- ret i17 trunc ( i32 zext ( i17 42 to i32) to i17 )
-}
-
-define i17 @"SExtConst" () {
- ret i17 trunc (i32 sext (i17 42 to i32) to i17 )
-}
diff --git a/llvm/test/Transforms/GlobalDCE/complex-constantexpr.ll b/llvm/test/Transforms/GlobalDCE/complex-constantexpr.ll
index 5083f707c1680df..1dd55eed947ecf6 100644
--- a/llvm/test/Transforms/GlobalDCE/complex-constantexpr.ll
+++ b/llvm/test/Transforms/GlobalDCE/complex-constantexpr.ll
@@ -24,9 +24,10 @@ bb1: ; preds = %bb11
bb2: ; preds = %bb1, %bb
%tmp3 = phi i32 [ %tmp, %bb1 ], [ 0, %bb ]
- %tmp4 = xor i32 %tmp3, zext (i1 icmp ne (i64 ptrtoint (ptr @global5 to i64), i64 1) to i32)
+ %ext = zext i1 icmp ne (i64 ptrtoint (ptr @global5 to i64), i64 1) to i32
+ %tmp4 = xor i32 %tmp3, %ext
store i32 %tmp4, ptr @global5, align 4
- %tmp5 = icmp eq i32 %tmp3, zext (i1 icmp ne (i64 ptrtoint (ptr @global5 to i64), i64 1) to i32)
+ %tmp5 = icmp eq i32 %tmp3, %ext
br i1 %tmp5, label %bb8, label %bb6
bb6: ; preds = %bb2
diff --git a/llvm/test/Transforms/GlobalOpt/dead-constant-user.ll b/llvm/test/Transforms/GlobalOpt/dead-constant-user.ll
index 87855e46571ec6a..648f5bee23cbb82 100644
--- a/llvm/test/Transforms/GlobalOpt/dead-constant-user.ll
+++ b/llvm/test/Transforms/GlobalOpt/dead-constant-user.ll
@@ -8,7 +8,7 @@ define void @test1() {
; CHECK-LABEL: @test1(
; CHECK-NEXT: ret void
;
- %xor4 = xor i32 zext (i1 icmp ne (ptr getelementptr (i8, ptr @g, i64 3), ptr null) to i32), 0
+ %xor4 = xor i1 add (i1 icmp ne (ptr getelementptr (i8, ptr @g, i64 3), ptr null), i1 1), 0
%t0 = load ptr, ptr getelementptr (i8, ptr @g, i64 3), align 1
%t1 = load i16, ptr %t0, align 1
ret void
diff --git a/llvm/test/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll b/llvm/test/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll
index 2e70a95dfde6233..68444db15d12a7d 100644
--- a/llvm/test/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll
+++ b/llvm/test/Transforms/InstCombine/2004-11-27-SetCCForCastLargerAndConstant.ll
@@ -34,7 +34,8 @@ define i1 @PR28011(i16 %a) {
; CHECK-NEXT: ret i1 [[CMP]]
;
%conv = sext i16 %a to i32
- %or = or i32 zext (i1 icmp ne (ptr @b, ptr @a) to i32), 1
+ %ext = zext i1 icmp ne (ptr @b, ptr @a) to i32
+ %or = or i32 %ext, 1
%cmp = icmp ne i32 %conv, %or
ret i1 %cmp
}
diff --git a/llvm/test/Transforms/InstCombine/2012-3-15-or-xor-constant.ll b/llvm/test/Transforms/InstCombine/2012-3-15-or-xor-constant.ll
index bf288064271d747..58b1d044b7d4614 100644
--- a/llvm/test/Transforms/InstCombine/2012-3-15-or-xor-constant.ll
+++ b/llvm/test/Transforms/InstCombine/2012-3-15-or-xor-constant.ll
@@ -15,7 +15,8 @@ define i32 @function(i32 %x) nounwind {
entry:
%xor = xor i32 %x, 1
store volatile i32 %xor, ptr inttoptr (i64 1 to ptr), align 4
- %or = or i32 zext (i1 icmp eq (ptr @g, ptr null) to i32), 1
+ %ext = zext i1 icmp eq (ptr @g, ptr null) to i32
+ %or = or i32 %ext, 1
%or4 = or i32 %or, %xor
ret i32 %or4
}
diff --git a/llvm/test/Transforms/InstCombine/constant-fold-compare.ll b/llvm/test/Transforms/InstCombine/constant-fold-compare.ll
index df6d63493de63e8..a9e447567c9b9a9 100644
--- a/llvm/test/Transforms/InstCombine/constant-fold-compare.ll
+++ b/llvm/test/Transforms/InstCombine/constant-fold-compare.ll
@@ -3,6 +3,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
define i32 @a() nounwind readnone {
entry:
- ret i32 zext (i1 icmp eq (i32 0, i32 ptrtoint (ptr @a to i32)) to i32)
+ %zext = zext i1 icmp eq (i32 0, i32 ptrtoint (ptr @a to i32)) to i32
+ ret i32 %zext
}
; CHECK: ret i32 0
diff --git a/llvm/test/Transforms/InstCombine/constant-fold-iteration.ll b/llvm/test/Transforms/InstCombine/constant-fold-iteration.ll
index cfef2540e455252..a441bfb653196c3 100644
--- a/llvm/test/Transforms/InstCombine/constant-fold-iteration.ll
+++ b/llvm/test/Transforms/InstCombine/constant-fold-iteration.ll
@@ -7,7 +7,8 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
define i32 @a() nounwind readnone {
entry:
- ret i32 zext (i1 icmp eq (i32 0, i32 ptrtoint (ptr @a to i32)) to i32)
+ %ext = zext i1 icmp eq (i32 0, i32 ptrtoint (ptr @a to i32)) to i32
+ ret i32 %ext
}
; CHECK: INSTCOMBINE ITERATION #1
; CHECK-NOT: INSTCOMBINE ITERATION #2
diff --git a/llvm/test/Transforms/InstCombine/fold-bin-operand.ll b/llvm/test/Transforms/InstCombine/fold-bin-operand.ll
index e225b201d743e39..fef8897ab08026a 100644
--- a/llvm/test/Transforms/InstCombine/fold-bin-operand.ll
+++ b/llvm/test/Transforms/InstCombine/fold-bin-operand.ll
@@ -22,7 +22,8 @@ define i32 @g(i32 %x) {
; CHECK-LABEL: @g(
; CHECK-NEXT: ret i32 [[X:%.*]]
;
- %b = add i32 %x, zext (i1 icmp eq (ptr inttoptr (i32 1000000 to ptr), ptr inttoptr (i32 2000000 to ptr)) to i32)
+ %ext = zext i1 icmp eq (ptr inttoptr (i32 1000000 to ptr), ptr inttoptr (i32 2000000 to ptr)) to i32
+ %b = add i32 %x, %ext
ret i32 %b
}
diff --git a/llvm/test/Transforms/InstCombine/icmp-mul.ll b/llvm/test/Transforms/InstCombine/icmp-mul.ll
index 262aafc1e929c63..7f76a94f395b606 100644
--- a/llvm/test/Transforms/InstCombine/icmp-mul.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-mul.ll
@@ -801,7 +801,8 @@ define i1 @oss_fuzz_39934(i32 %arg) {
; CHECK-NEXT: ret i1 [[C10]]
;
%B13 = mul nsw i32 %arg, -65536
- %or = or i32 zext (i1 icmp eq (ptr @g, ptr null) to i32), 65537
+ %ext = zext i1 icmp eq (ptr @g, ptr null) to i32
+ %or = or i32 %ext, 65537
%mul = mul i32 %or, -65536
%C10 = icmp ne i32 %mul, %B13
ret i1 %C10
diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll
index a5c05278f4232e8..78ac730cf026ed9 100644
--- a/llvm/test/Transforms/InstCombine/icmp.ll
+++ b/llvm/test/Transforms/InstCombine/icmp.ll
@@ -3468,10 +3468,16 @@ define i1 @f9(i32 %val, i32 %lim) {
define i1 @f10(i16 %p) {
; CHECK-LABEL: @f10(
-; CHECK-NEXT: [[CMP580:%.*]] = icmp uge i16 [[P:%.*]], mul (i16 zext (i8 ptrtoint (ptr @f10 to i8) to i16), i16 zext (i8 ptrtoint (ptr @f10 to i8) to i16))
+; CHECK-NEXT: [[EXT1:%.*]] = zext i8 ptrtoint (ptr @f10 to i8) to i16
+; CHECK-NEXT: [[EXT2:%.*]] = zext i8 ptrtoint (ptr @f10 to i8) to i16
+; CHECK-NEXT: [[MUL:%.*]] = mul nuw i16 [[EXT1]], [[EXT2]]
+; CHECK-NEXT: [[CMP580:%.*]] = icmp ule i16 [[MUL]], [[P:%.*]]
; CHECK-NEXT: ret i1 [[CMP580]]
;
- %cmp580 = icmp ule i16 mul (i16 zext (i8 ptrtoint (ptr @f10 to i8) to i16), i16 zext (i8 ptrtoint (ptr @f10 to i8) to i16)), %p
+ %ext1 = zext i8 ptrtoint (ptr @f10 to i8) to i16
+ %ext2 = zext i8 ptrtoint (ptr @f10 to i8) to i16
+ %mul = mul i16 %ext1, %ext2
+ %cmp580 = icmp ule i16 %mul, %p
ret i1 %cmp580
}
diff --git a/llvm/test/Transforms/InstCombine/mul-inseltpoison.ll b/llvm/test/Transforms/InstCombine/mul-inseltpoison.ll
index f2e618173367ae6..448558d755a5763 100644
--- a/llvm/test/Transforms/InstCombine/mul-inseltpoison.ll
+++ b/llvm/test/Transforms/InstCombine/mul-inseltpoison.ll
@@ -570,10 +570,13 @@ define i64 @test30(i32 %A, i32 %B) {
@PR22087 = external global i32
define i32 @test31(i32 %V) {
; CHECK-LABEL: @test31(
-; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[V:%.*]], shl (i32 1, i32 zext (i1 icmp ne (ptr inttoptr (i64 1 to ptr), ptr @PR22087) to i32))
-; CHECK-NEXT: ret i32 [[MUL]]
+; CHECK-NEXT: [[EXT:%.*]] = zext i1 icmp ne (ptr inttoptr (i64 1 to ptr), ptr @PR22087) to i32
+; CHECK-NEXT: [[MUL1:%.*]] = shl i32 [[V:%.*]], [[EXT]]
+; CHECK-NEXT: ret i32 [[MUL1]]
;
- %mul = mul i32 %V, shl (i32 1, i32 zext (i1 icmp ne (ptr inttoptr (i64 1 to ptr), ptr @PR22087) to i32))
+ %ext = zext i1 icmp ne (ptr inttoptr (i64 1 to ptr), ptr @PR22087) to i32
+ %shl = shl i32 1, %ext
+ %mul = mul i32 %V, %shl
ret i32 %mul
}
diff --git a/llvm/test/Transforms/InstCombine/mul.ll b/llvm/test/Transforms/InstCombine/mul.ll
index 45a837a2a594aab..55092e93d09274b 100644
--- a/llvm/test/Transforms/InstCombine/mul.ll
+++ b/llvm/test/Transforms/InstCombine/mul.ll
@@ -1131,10 +1131,13 @@ define i64 @test30(i32 %A, i32 %B) {
@PR22087 = external global i32
define i32 @test31(i32 %V) {
; CHECK-LABEL: @test31(
-; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[V:%.*]], shl (i32 1, i32 zext (i1 icmp ne (ptr inttoptr (i64 1 to ptr), ptr @PR22087) to i32))
-; CHECK-NEXT: ret i32 [[MUL]]
+; CHECK-NEXT: [[EXT:%.*]] = zext i1 icmp ne (ptr inttoptr (i64 1 to ptr), ptr @PR22087) to i32
+; CHECK-NEXT: [[MUL1:%.*]] = shl i32 [[V:%.*]], [[EXT]]
+; CHECK-NEXT: ret i32 [[MUL1]]
;
- %mul = mul i32 %V, shl (i32 1, i32 zext (i1 icmp ne (ptr inttoptr (i64 1 to ptr), ptr @PR22087) to i32))
+ %ext = zext i1 icmp ne (ptr inttoptr (i64 1 to ptr), ptr @PR22087) to i32
+ %shl = shl i32 1, %ext
+ %mul = mul i32 %V, %shl
ret i32 %mul
}
diff --git a/llvm/test/Transforms/InstCombine/not-add.ll b/llvm/test/Transforms/InstCombine/not-add.ll
index c14410b5008fe78..877f558ffd5037b 100644
--- a/llvm/test/Transforms/InstCombine/not-add.ll
+++ b/llvm/test/Transforms/InstCombine/not-add.ll
@@ -175,7 +175,8 @@ define void @pr50370(i32 %x) {
;
entry:
%xor = xor i32 %x, 1
- %or = or i32 zext (i1 icmp eq (ptr @g, ptr null) to i32), 1
+ %ext = zext i1 icmp eq (ptr @g, ptr null) to i32
+ %or = or i32 %ext, 1
%or4 = or i32 %or, 65536
%B6 = ashr i32 65536, %or4
%B15 = srem i32 %B6, %xor
diff --git a/llvm/test/Transforms/InstCombine/overflow-mul.ll b/llvm/test/Transforms/InstCombine/overflow-mul.ll
index 8b92eda402bca7e..9a9b18bde7567a9 100644
--- a/llvm/test/Transforms/InstCombine/overflow-mul.ll
+++ b/llvm/test/Transforms/InstCombine/overflow-mul.ll
@@ -237,7 +237,8 @@ define i1 @pr21445(i8 %a) {
; CHECK-NEXT: ret i1 [[CMP]]
;
%ext = zext i8 %a to i32
- %mul = mul i32 %ext, zext (i8 ptrtoint (ptr @pr21445_data to i8) to i32)
+ %ext2 = zext i8 ptrtoint (ptr @pr21445_data to i8) to i32
+ %mul = mul i32 %ext, %ext2
%and = and i32 %mul, 255
%cmp = icmp ne i32 %mul, %and
ret i1 %cmp
diff --git a/llvm/test/Transforms/InstCombine/pr32686.ll b/llvm/test/Transforms/InstCombine/pr32686.ll
index d77f30e31320a5c..39f9803683c3363 100644
--- a/llvm/test/Transforms/InstCombine/pr32686.ll
+++ b/llvm/test/Transforms/InstCombine/pr32686.ll
@@ -9,7 +9,9 @@ define void @tinkywinky() {
; CHECK-NEXT: [[PATATINO:%.*]] = load i8, ptr @a, align 1
; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq i8 [[PATATINO]], 0
; CHECK-NEXT: [[LNOT_EXT:%.*]] = zext i1 [[TOBOOL_NOT]] to i32
-; CHECK-NEXT: [[OR:%.*]] = or i32 [[LNOT_EXT]], xor (i32 zext (i1 icmp ne (ptr @a, ptr @b) to i32), i32 2)
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i1 icmp ne (ptr @a, ptr @b) to i32
+; CHECK-NEXT: [[XOR1:%.*]] = or i32 [[ZEXT]], [[LNOT_EXT]]
+; CHECK-NEXT: [[OR:%.*]] = or i32 [[XOR1]], 2
; CHECK-NEXT: store i32 [[OR]], ptr @b, align 4
; CHECK-NEXT: ret void
;
@@ -17,7 +19,9 @@ define void @tinkywinky() {
%tobool = icmp ne i8 %patatino, 0
%lnot = xor i1 %tobool, true
%lnot.ext = zext i1 %lnot to i32
- %or = or i32 xor (i32 zext (i1 icmp ne (ptr @a, ptr @b) to i32), i32 2), %lnot.ext
+ %zext = zext i1 icmp ne (ptr @a, ptr @b) to i32
+ %xor = xor i32 %zext, 2
+ %or = or i32 %xor, %lnot.ext
store i32 %or, ptr @b, align 4
ret void
}
diff --git a/llvm/test/Transforms/InstCombine/pr35515.ll b/llvm/test/Transforms/InstCombine/pr35515.ll
index 9fdc0c00f5b7b6d..7bc14c1c1b40bc2 100644
--- a/llvm/test/Transforms/InstCombine/pr35515.ll
+++ b/llvm/test/Transforms/InstCombine/pr35515.ll
@@ -9,7 +9,11 @@ define i40 @func_24() {
entry:
%bf.load81 = load i40, ptr @g_49, align 2
%bf.clear = and i40 %bf.load81, -274869518337
- %bf.set = or i40 %bf.clear, shl (i40 zext (i1 icmp sgt (i32 zext (i1 icmp eq (ptr getelementptr inbounds ([6 x i8], ptr @g_461, i64 0, i64 2), ptr @g_40) to i32), i32 0) to i40), i40 23)
+ %zext1 = zext i1 icmp eq (ptr getelementptr inbounds ([6 x i8], ptr @g_461, i64 0, i64 2), ptr @g_40) to i32
+ %cmp = icmp sgt i32 %zext1, 0
+ %zext2 = zext i1 %cmp to i40
+ %shl = shl i40 %zext2, 23
+ %bf.set = or i40 %bf.clear, %shl
%tmp = lshr i40 %bf.set, 23
%tmp1 = trunc i40 %tmp to i32
%tmp2 = and i32 1, %tmp1
diff --git a/llvm/test/Transforms/InstCombine/rem.ll b/llvm/test/Transforms/InstCombine/rem.ll
index b5a71681522a385..878581c3518acb0 100644
--- a/llvm/test/Transforms/InstCombine/rem.ll
+++ b/llvm/test/Transforms/InstCombine/rem.ll
@@ -540,7 +540,8 @@ if.end:
br i1 icmp eq (ptr getelementptr inbounds ([5 x i16], ptr @a, i64 0, i64 4), ptr @b), label %rem.is.safe, label %rem.is.unsafe
rem.is.safe:
- %rem = srem i32 %lhs, zext (i1 icmp eq (ptr getelementptr inbounds ([5 x i16], ptr @a, i64 0, i64 4), ptr @b) to i32)
+ %ext = zext i1 icmp eq (ptr getelementptr inbounds ([5 x i16], ptr @a, i64 0, i64 4), ptr @b) to i32
+ %rem = srem i32 %lhs, %ext
ret i32 %rem
rem.is.unsafe:
@@ -608,7 +609,8 @@ if.end:
br i1 icmp eq (ptr getelementptr inbounds ([5 x i16], ptr @a, i64 0, i64 4), ptr @b), label %rem.is.safe, label %rem.is.unsafe
rem.is.safe:
- %rem = urem i32 %lhs, zext (i1 icmp eq (ptr getelementptr inbounds ([5 x i16], ptr @a, i64 0, i64 4), ptr @b) to i32)
+ %ext = zext i1 icmp eq (ptr getelementptr inbounds ([5 x i16], ptr @a, i64 0, i64 4), ptr @b) to i32
+ %rem = urem i32 %lhs, %ext
ret i32 %rem
rem.is.unsafe:
diff --git a/llvm/test/Transforms/InstCombine/shift-amount-reassociation-in-bittest.ll b/llvm/test/Transforms/InstCombine/shift-amount-reassociation-in-bittest.ll
index a539ee320674e0f..0262db1a01e5cff 100644
--- a/llvm/test/Transforms/InstCombine/shift-amount-reassociation-in-bittest.ll
+++ b/llvm/test/Transforms/InstCombine/shift-amount-reassociation-in-bittest.ll
@@ -675,14 +675,17 @@ define i1 @constantexpr() {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP0:%.*]] = load i16, ptr @f.a, align 2
; CHECK-NEXT: [[TMP1:%.*]] = lshr i16 [[TMP0]], 1
-; CHECK-NEXT: [[TMP2:%.*]] = and i16 [[TMP1]], shl (i16 1, i16 zext (i1 icmp ne (i16 ptrtoint (ptr @f.a to i16), i16 1) to i16))
-; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i16 [[TMP2]], 0
+; CHECK-NEXT: [[ZEXT:%.*]] = zext i1 icmp ne (i16 ptrtoint (ptr @f.a to i16), i16 1) to i16
+; CHECK-NEXT: [[TMP2:%.*]] = shl nuw nsw i16 1, [[ZEXT]]
+; CHECK-NEXT: [[TMP3:%.*]] = and i16 [[TMP1]], [[TMP2]]
+; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i16 [[TMP3]], 0
; CHECK-NEXT: ret i1 [[TOBOOL]]
;
entry:
%0 = load i16, ptr @f.a
%shr = ashr i16 %0, 1
- %shr1 = ashr i16 %shr, zext (i1 icmp ne (i16 ptrtoint (ptr @f.a to i16), i16 1) to i16)
+ %zext = zext i1 icmp ne (i16 ptrtoint (ptr @f.a to i16), i16 1) to i16
+ %shr1 = ashr i16 %shr, %zext
%and = and i16 %shr1, 1
%tobool = icmp ne i16 %and, 0
ret i1 %tobool
diff --git a/llvm/test/Transforms/InstCombine/udiv-simplify.ll b/llvm/test/Transforms/InstCombine/udiv-simplify.ll
index a38d32d7925500f..c55f64e65922e03 100644
--- a/llvm/test/Transforms/InstCombine/udiv-simplify.ll
+++ b/llvm/test/Transforms/InstCombine/udiv-simplify.ll
@@ -55,11 +55,13 @@ define i64 @test2_PR2274(i32 %x, i32 %v) nounwind {
define i32 @PR30366(i1 %a) {
; CHECK-LABEL: @PR30366(
; CHECK-NEXT: [[Z:%.*]] = zext i1 [[A:%.*]] to i32
-; CHECK-NEXT: [[D:%.*]] = udiv i32 [[Z]], zext (i16 shl (i16 1, i16 ptrtoint (ptr @b to i16)) to i32)
+; CHECK-NEXT: [[Z2:%.*]] = zext i16 shl (i16 1, i16 ptrtoint (ptr @b to i16)) to i32
+; CHECK-NEXT: [[D:%.*]] = udiv i32 [[Z]], [[Z2]]
; CHECK-NEXT: ret i32 [[D]]
;
%z = zext i1 %a to i32
- %d = udiv i32 %z, zext (i16 shl (i16 1, i16 ptrtoint (ptr @b to i16)) to i32)
+ %z2 = zext i16 shl (i16 1, i16 ptrtoint (ptr @b to i16)) to i32
+ %d = udiv i32 %z, %z2
ret i32 %d
}
diff --git a/llvm/test/Transforms/InstCombine/udivrem-change-width.ll b/llvm/test/Transforms/InstCombine/udivrem-change-width.ll
index 97ec9aa4b0c35bb..f4094cf5008adb0 100644
--- a/llvm/test/Transforms/InstCombine/udivrem-change-width.ll
+++ b/llvm/test/Transforms/InstCombine/udivrem-change-width.ll
@@ -283,7 +283,8 @@ define i32 @udiv_constexpr(i8 %a) {
; CHECK-NEXT: ret i32 [[D]]
;
%za = zext i8 %a to i32
- %d = udiv i32 %za, zext (i8 ptrtoint (ptr @b to i8) to i32)
+ %zb = zext i8 ptrtoint (ptr @b to i8) to i32
+ %d = udiv i32 %za, %zb
ret i32 %d
}
@@ -293,10 +294,12 @@ define i32 @udiv_constexpr(i8 %a) {
define i32 @udiv_const_constexpr(i8 %a) {
; CHECK-LABEL: @udiv_const_constexpr(
-; CHECK-NEXT: [[D:%.*]] = udiv i32 42, zext (i8 ptrtoint (ptr @g1 to i8) to i32)
+; CHECK-NEXT: [[TMP1:%.*]] = udiv i8 42, ptrtoint (ptr @g1 to i8)
+; CHECK-NEXT: [[D:%.*]] = zext i8 [[TMP1]] to i32
; CHECK-NEXT: ret i32 [[D]]
;
- %d = udiv i32 42, zext (i8 ptrtoint (ptr @g1 to i8) to i32)
+ %z = zext i8 ptrtoint (ptr @g1 to i8) to i32
+ %d = udiv i32 42, %z
ret i32 %d
}
@@ -306,10 +309,12 @@ define i32 @udiv_const_constexpr(i8 %a) {
define i32 @urem_const_constexpr(i8 %a) {
; CHECK-LABEL: @urem_const_constexpr(
-; CHECK-NEXT: [[D:%.*]] = urem i32 42, zext (i8 ptrtoint (ptr @g2 to i8) to i32)
+; CHECK-NEXT: [[TMP1:%.*]] = urem i8 42, ptrtoint (ptr @g2 to i8)
+; CHECK-NEXT: [[D:%.*]] = zext i8 [[TMP1]] to i32
; CHECK-NEXT: ret i32 [[D]]
;
- %d = urem i32 42, zext (i8 ptrtoint (ptr @g2 to i8) to i32)
+ %z = zext i8 ptrtoint (ptr @g2 to i8) to i32
+ %d = urem i32 42, %z
ret i32 %d
}
@@ -317,10 +322,12 @@ define i32 @urem_const_constexpr(i8 %a) {
define i32 @udiv_constexpr_const(i8 %a) {
; CHECK-LABEL: @udiv_constexpr_const(
-; CHECK-NEXT: [[D:%.*]] = udiv i32 zext (i8 ptrtoint (ptr @g3 to i8) to i32), 42
+; CHECK-NEXT: [[TMP1:%.*]] = udiv i8 ptrtoint (ptr @g3 to i8), 42
+; CHECK-NEXT: [[D:%.*]] = zext i8 [[TMP1]] to i32
; CHECK-NEXT: ret i32 [[D]]
;
- %d = udiv i32 zext (i8 ptrtoint (ptr @g3 to i8) to i32), 42
+ %z = zext i8 ptrtoint (ptr @g3 to i8) to i32
+ %d = udiv i32 %z, 42
ret i32 %d
}
@@ -328,9 +335,11 @@ define i32 @udiv_constexpr_const(i8 %a) {
define i32 @urem_constexpr_const(i8 %a) {
; CHECK-LABEL: @urem_constexpr_const(
-; CHECK-NEXT: [[D:%.*]] = urem i32 zext (i8 ptrtoint (ptr @g4 to i8) to i32), 42
+; CHECK-NEXT: [[TMP1:%.*]] = urem i8 ptrtoint (ptr @g4 to i8), 42
+; CHECK-NEXT: [[D:%.*]] = zext i8 [[TMP1]] to i32
; CHECK-NEXT: ret i32 [[D]]
;
- %d = urem i32 zext (i8 ptrtoint (ptr @g4 to i8) to i32), 42
+ %z = zext i8 ptrtoint (ptr @g4 to i8) to i32
+ %d = urem i32 %z, 42
ret i32 %d
}
diff --git a/llvm/test/Transforms/InstSimplify/ConstProp/constant-expr.ll b/llvm/test/Transforms/InstSimplify/ConstProp/constant-expr.ll
index 7634a4a120f64c4..f46f88901de7c56 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/constant-expr.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/constant-expr.ll
@@ -28,15 +28,8 @@
@N = global i1 icmp ne (i1 icmp ult (ptr @X, ptr @Y), i1 false)
; CHECK: @N = global i1 icmp ult (ptr @X, ptr @Y)
- at O = global i1 icmp eq (i32 zext (i1 icmp ult (ptr @X, ptr @Y) to i32), i32 0)
-; CHECK: @O = global i1 icmp uge (ptr @X, ptr @Y)
-
; PR9011
- at pr9011_1 = constant <4 x i32> zext (<4 x i8> zeroinitializer to <4 x i32>)
-; CHECK: pr9011_1 = constant <4 x i32> zeroinitializer
- at pr9011_2 = constant <4 x i32> sext (<4 x i8> zeroinitializer to <4 x i32>)
-; CHECK: pr9011_2 = constant <4 x i32> zeroinitializer
@pr9011_3 = constant <4 x i32> bitcast (<16 x i8> zeroinitializer to <4 x i32>)
; CHECK: pr9011_3 = constant <4 x i32> zeroinitializer
@pr9011_4 = constant <4 x float> uitofp (<4 x i8> zeroinitializer to <4 x float>)
diff --git a/llvm/test/Transforms/JumpThreading/constant-fold-status.ll b/llvm/test/Transforms/JumpThreading/constant-fold-status.ll
index 5d452d65e811c73..ae984df1caa3bd6 100644
--- a/llvm/test/Transforms/JumpThreading/constant-fold-status.ll
+++ b/llvm/test/Transforms/JumpThreading/constant-fold-status.ll
@@ -14,7 +14,7 @@
define void @foo(i16 %d) {
entry:
- %.not = icmp eq i16 zext (i1 icmp ne (i32 ptrtoint (ptr @a to i32), i32 0) to i16), 0
+ %.not = icmp eq i32 ptrtoint (ptr @a to i32), 0
br i1 %.not, label %overflow, label %cont
overflow: ; preds = %entry
diff --git a/llvm/test/Transforms/SCCP/undef-resolve.ll b/llvm/test/Transforms/SCCP/undef-resolve.ll
index 9aecadaec0ee2e6..83058544a46f57c 100644
--- a/llvm/test/Transforms/SCCP/undef-resolve.ll
+++ b/llvm/test/Transforms/SCCP/undef-resolve.ll
@@ -43,10 +43,10 @@ define i32 @test2() nounwind readnone ssp {
; CHECK: control.us:
; CHECK-NEXT: [[SWITCHCOND_0_US]] = phi i32 [ [[A_0_PH_US]], [[BB0_US:%.*]] ], [ [[SWITCHCOND_0_PH_US]], [[CONTROL_OUTER_US]] ]
; CHECK-NEXT: switch i32 [[SWITCHCOND_0_US]], label [[CONTROL_OUTER_LOOPEXIT_US_LCSSA_US:%.*]] [
-; CHECK-NEXT: i32 0, label [[BB0_US]]
-; CHECK-NEXT: i32 1, label [[BB1_US_LCSSA_US:%.*]]
-; CHECK-NEXT: i32 3, label [[BB3_US]]
-; CHECK-NEXT: i32 4, label [[BB4_US_LCSSA_US:%.*]]
+; CHECK-NEXT: i32 0, label [[BB0_US]]
+; CHECK-NEXT: i32 1, label [[BB1_US_LCSSA_US:%.*]]
+; CHECK-NEXT: i32 3, label [[BB3_US]]
+; CHECK-NEXT: i32 4, label [[BB4_US_LCSSA_US:%.*]]
; CHECK-NEXT: ]
; CHECK: control.outer.loopexit.us-lcssa.us:
; CHECK-NEXT: br label [[CONTROL_OUTER_LOOPEXIT]]
@@ -61,10 +61,10 @@ define i32 @test2() nounwind readnone ssp {
; CHECK: control:
; CHECK-NEXT: [[SWITCHCOND_0:%.*]] = phi i32 [ [[A_0_PH]], [[BB0:%.*]] ], [ [[SWITCHCOND_0_PH]], [[CONTROL_OUTER]] ]
; CHECK-NEXT: switch i32 [[SWITCHCOND_0]], label [[CONTROL_OUTER_LOOPEXIT_US_LCSSA:%.*]] [
-; CHECK-NEXT: i32 0, label [[BB0]]
-; CHECK-NEXT: i32 1, label [[BB1_US_LCSSA:%.*]]
-; CHECK-NEXT: i32 3, label [[BB3]]
-; CHECK-NEXT: i32 4, label [[BB4_US_LCSSA:%.*]]
+; CHECK-NEXT: i32 0, label [[BB0]]
+; CHECK-NEXT: i32 1, label [[BB1_US_LCSSA:%.*]]
+; CHECK-NEXT: i32 3, label [[BB3]]
+; CHECK-NEXT: i32 4, label [[BB4_US_LCSSA:%.*]]
; CHECK-NEXT: ]
; CHECK: bb4.us-lcssa:
; CHECK-NEXT: br label [[BB4]]
@@ -258,11 +258,13 @@ entry:
define i32 @test11(i1 %tobool) {
; CHECK-LABEL: @test11(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[SHR4:%.*]] = ashr i32 undef, zext (i1 icmp eq (ptr @test11, ptr @GV) to i32)
+; CHECK-NEXT: [[EXT:%.*]] = zext i1 icmp eq (ptr @test11, ptr @GV) to i32
+; CHECK-NEXT: [[SHR4:%.*]] = ashr i32 undef, [[EXT]]
; CHECK-NEXT: ret i32 [[SHR4]]
;
entry:
- %shr4 = ashr i32 undef, zext (i1 icmp eq (ptr @test11, ptr @GV) to i32)
+ %ext = zext i1 icmp eq (ptr @test11, ptr @GV) to i32
+ %shr4 = ashr i32 undef, %ext
ret i32 %shr4
}
diff --git a/llvm/test/Transforms/SLPVectorizer/X86/bad-reduction.ll b/llvm/test/Transforms/SLPVectorizer/X86/bad-reduction.ll
index e1de16ffbd1868d..dcc9693860322ea 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/bad-reduction.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/bad-reduction.ll
@@ -523,17 +523,25 @@ define void @PR39538(ptr %t0, ptr %t1) {
define void @load_combine_constant_expression(ptr %t1) {
; CHECK-LABEL: @load_combine_constant_expression(
-; CHECK-NEXT: [[OR1:%.*]] = or i64 shl (i64 zext (i32 ptrtoint (ptr @g1 to i32) to i64), i64 32), zext (i32 ptrtoint (ptr @g2 to i32) to i64)
+; CHECK-NEXT: [[EXT1:%.*]] = zext i32 ptrtoint (ptr @g1 to i32) to i64
+; CHECK-NEXT: [[EXT2:%.*]] = zext i32 ptrtoint (ptr @g2 to i32) to i64
+; CHECK-NEXT: [[SHL1:%.*]] = shl i64 [[EXT1]], 32
+; CHECK-NEXT: [[OR1:%.*]] = or i64 [[SHL1]], [[EXT2]]
; CHECK-NEXT: store i64 [[OR1]], ptr [[T1:%.*]], align 4
; CHECK-NEXT: [[T3:%.*]] = getelementptr i64, ptr [[T1]], i64 1
-; CHECK-NEXT: [[OR2:%.*]] = or i64 shl (i64 zext (i32 ptrtoint (ptr @g1 to i32) to i64), i64 32), zext (i32 ptrtoint (ptr @g2 to i32) to i64)
+; CHECK-NEXT: [[SHL2:%.*]] = shl i64 [[EXT1]], 32
+; CHECK-NEXT: [[OR2:%.*]] = or i64 [[SHL2]], [[EXT2]]
; CHECK-NEXT: store i64 [[OR2]], ptr [[T3]], align 4
; CHECK-NEXT: ret void
;
- %or1 = or i64 shl (i64 zext (i32 ptrtoint (ptr @g1 to i32) to i64), i64 32), zext (i32 ptrtoint (ptr @g2 to i32) to i64)
+ %ext1 = zext i32 ptrtoint (ptr @g1 to i32) to i64
+ %ext2 = zext i32 ptrtoint (ptr @g2 to i32) to i64
+ %shl1 = shl i64 %ext1, 32
+ %or1 = or i64 %shl1, %ext2
store i64 %or1, ptr %t1, align 4
%t3 = getelementptr i64, ptr %t1, i64 1
- %or2 = or i64 shl (i64 zext (i32 ptrtoint (ptr @g1 to i32) to i64), i64 32), zext (i32 ptrtoint (ptr @g2 to i32) to i64)
+ %shl2 = shl i64 %ext1, 32
+ %or2 = or i64 %shl2, %ext2
store i64 %or2, ptr %t3, align 4
ret void
}
diff --git a/llvm/unittests/IR/ConstantsTest.cpp b/llvm/unittests/IR/ConstantsTest.cpp
index e905452f32b368f..158c0fe928ce7e7 100644
--- a/llvm/unittests/IR/ConstantsTest.cpp
+++ b/llvm/unittests/IR/ConstantsTest.cpp
@@ -253,8 +253,6 @@ TEST(ConstantsTest, AsInstructionsTest) {
CHECK(ConstantExpr::getAShr(P0, P0, true),
"ashr exact i32 " P0STR ", " P0STR);
- CHECK(ConstantExpr::getSExt(P0, Int64Ty), "sext i32 " P0STR " to i64");
- CHECK(ConstantExpr::getZExt(P0, Int64Ty), "zext i32 " P0STR " to i64");
CHECK(ConstantExpr::getFPTrunc(P2, FloatTy),
"fptrunc double " P2STR " to float");
CHECK(ConstantExpr::getFPExtend(P1, DoubleTy),
More information about the llvm-commits
mailing list