diff --git a/llvm/bindings/ocaml/llvm/llvm.ml b/llvm/bindings/ocaml/llvm/llvm.ml index cabf32cae376f..581d832430074 100644 --- a/llvm/bindings/ocaml/llvm/llvm.ml +++ b/llvm/bindings/ocaml/llvm/llvm.ml @@ -661,12 +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_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" -external const_sitofp : llvalue -> lltype -> llvalue = "llvm_const_sitofp" -external const_fptoui : llvalue -> lltype -> llvalue = "llvm_const_fptoui" -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" @@ -674,7 +668,6 @@ external const_trunc_or_bitcast : llvalue -> lltype -> llvalue = "llvm_const_trunc_or_bitcast" external const_pointercast : llvalue -> lltype -> llvalue = "llvm_const_pointercast" -external const_fpcast : llvalue -> lltype -> llvalue = "llvm_const_fpcast" external const_extractelement : llvalue -> llvalue -> llvalue = "llvm_const_extractelement" external const_insertelement : llvalue -> llvalue -> llvalue -> llvalue diff --git a/llvm/bindings/ocaml/llvm/llvm.mli b/llvm/bindings/ocaml/llvm/llvm.mli index ee691ca836244..f9aab89e4bddf 100644 --- a/llvm/bindings/ocaml/llvm/llvm.mli +++ b/llvm/bindings/ocaml/llvm/llvm.mli @@ -1171,36 +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_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]. *) -val const_fptrunc : llvalue -> lltype -> llvalue - -(** [const_fpext c ty] returns the constant extension of floating point constant - [c] to the larger floating point type [ty]. - See the method [llvm::ConstantExpr::getFPExt]. *) -val const_fpext : llvalue -> lltype -> llvalue - -(** [const_uitofp c ty] returns the constant floating point conversion of - unsigned integer constant [c] to the floating point type [ty]. - See the method [llvm::ConstantExpr::getUIToFP]. *) -val const_uitofp : llvalue -> lltype -> llvalue - -(** [const_sitofp c ty] returns the constant floating point conversion of - signed integer constant [c] to the floating point type [ty]. - See the method [llvm::ConstantExpr::getSIToFP]. *) -val const_sitofp : llvalue -> lltype -> llvalue - -(** [const_fptoui c ty] returns the constant unsigned integer conversion of - floating point constant [c] to integer type [ty]. - See the method [llvm::ConstantExpr::getFPToUI]. *) -val const_fptoui : llvalue -> lltype -> llvalue - -(** [const_fptoui c ty] returns the constant unsigned integer conversion of - floating point constant [c] to integer type [ty]. - See the method [llvm::ConstantExpr::getFPToSI]. *) -val const_fptosi : llvalue -> lltype -> llvalue - (** [const_ptrtoint c ty] returns the constant integer conversion of pointer constant [c] to integer type [ty]. See the method [llvm::ConstantExpr::getPtrToInt]. *) @@ -1226,11 +1196,6 @@ val const_trunc_or_bitcast : llvalue -> lltype -> llvalue See the method [llvm::ConstantExpr::getPointerCast]. *) val const_pointercast : llvalue -> lltype -> 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]. *) -val const_fpcast : llvalue -> lltype -> llvalue - (** [const_extractelement vec i] returns the constant [i]th element of constant vector [vec]. [i] must be a constant [i32] value unsigned less than the size of the vector. diff --git a/llvm/bindings/ocaml/llvm/llvm_ocaml.c b/llvm/bindings/ocaml/llvm/llvm_ocaml.c index 7c5df6643d21a..4c4c49027206c 100644 --- a/llvm/bindings/ocaml/llvm/llvm_ocaml.c +++ b/llvm/bindings/ocaml/llvm/llvm_ocaml.c @@ -1271,42 +1271,6 @@ value llvm_const_trunc(value CV, value 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)); - return to_val(Value); -} - -/* llvalue -> lltype -> llvalue */ -value llvm_const_fpext(value CV, value T) { - LLVMValueRef Value = LLVMConstFPExt(Value_val(CV), Type_val(T)); - return to_val(Value); -} - -/* llvalue -> lltype -> llvalue */ -value llvm_const_uitofp(value CV, value T) { - LLVMValueRef Value = LLVMConstUIToFP(Value_val(CV), Type_val(T)); - return to_val(Value); -} - -/* llvalue -> lltype -> llvalue */ -value llvm_const_sitofp(value CV, value T) { - LLVMValueRef Value = LLVMConstSIToFP(Value_val(CV), Type_val(T)); - return to_val(Value); -} - -/* llvalue -> lltype -> llvalue */ -value llvm_const_fptoui(value CV, value T) { - LLVMValueRef Value = LLVMConstFPToUI(Value_val(CV), Type_val(T)); - return to_val(Value); -} - -/* llvalue -> lltype -> llvalue */ -value llvm_const_fptosi(value CV, value T) { - LLVMValueRef Value = LLVMConstFPToSI(Value_val(CV), Type_val(T)); - return to_val(Value); -} - /* llvalue -> lltype -> llvalue */ value llvm_const_ptrtoint(value CV, value T) { LLVMValueRef Value = LLVMConstPtrToInt(Value_val(CV), Type_val(T)); @@ -1337,12 +1301,6 @@ value llvm_const_pointercast(value CV, value T) { return to_val(Value); } -/* llvalue -> lltype -> llvalue */ -value llvm_const_fpcast(value CV, value T) { - LLVMValueRef Value = LLVMConstFPCast(Value_val(CV), Type_val(T)); - return to_val(Value); -} - /* llvalue -> llvalue -> llvalue */ value llvm_const_extractelement(value V, value I) { LLVMValueRef Value = LLVMConstExtractElement(Value_val(V), Value_val(I)); diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index 46a4b6d19e71b..385ea1e567dd3 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -4657,38 +4657,6 @@ The following is the syntax for constant expressions: ``trunc (CST to TYPE)`` Perform the :ref:`trunc operation ` on constants. -``fptrunc (CST to TYPE)`` - Truncate a floating-point constant to another floating-point type. - The size of CST must be larger than the size of TYPE. Both types - must be floating-point. -``fpext (CST to TYPE)`` - Floating-point extend a constant to another type. The size of CST - must be smaller or equal to the size of TYPE. Both types must be - floating-point. -``fptoui (CST to TYPE)`` - Convert a floating-point constant to the corresponding unsigned - integer constant. TYPE must be a scalar or vector integer type. CST - must be of scalar or vector floating-point type. Both CST and TYPE - must be scalars, or vectors of the same number of elements. If the - value won't fit in the integer type, the result is a - :ref:`poison value `. -``fptosi (CST to TYPE)`` - Convert a floating-point constant to the corresponding signed - integer constant. TYPE must be a scalar or vector integer type. CST - must be of scalar or vector floating-point type. Both CST and TYPE - must be scalars, or vectors of the same number of elements. If the - value won't fit in the integer type, the result is a - :ref:`poison value `. -``uitofp (CST to TYPE)`` - Convert an unsigned integer constant to the corresponding - floating-point constant. TYPE must be a scalar or vector floating-point - type. CST must be of scalar or vector integer type. Both CST and TYPE must - be scalars, or vectors of the same number of elements. -``sitofp (CST to TYPE)`` - Convert a signed integer constant to the corresponding floating-point - constant. TYPE must be a scalar or vector floating-point type. - CST must be of scalar or vector integer type. Both CST and TYPE must - be scalars, or vectors of the same number of elements. ``ptrtoint (CST to TYPE)`` Perform the :ref:`ptrtoint operation ` on constants. ``inttoptr (CST to TYPE)`` diff --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst index 23b54e6a37a74..2544aebaf2a22 100644 --- a/llvm/docs/ReleaseNotes.rst +++ b/llvm/docs/ReleaseNotes.rst @@ -59,6 +59,12 @@ Changes to the LLVM IR * ``or`` * ``zext`` * ``sext`` + * ``fptrunc`` + * ``fpext`` + * ``fptoui`` + * ``fptosi`` + * ``uitofp`` + * ``sitofp`` * Added `llvm.exp10` intrinsic. @@ -173,6 +179,13 @@ Changes to the C API * ``LLVMConstZExtOrBitCast`` * ``LLVMConstSExtOrBitCast`` * ``LLVMConstIntCast`` + * ``LLVMConstFPTrunc`` + * ``LLVMConstFPExt`` + * ``LLVMConstFPToUI`` + * ``LLVMConstFPToSI`` + * ``LLVMConstUIToFP`` + * ``LLVMConstSIToFP`` + * ``LLVMConstFPCast`` * 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 4fc88b2b64eac..ceeb74bd4e6fa 100644 --- a/llvm/include/llvm-c/Core.h +++ b/llvm/include/llvm-c/Core.h @@ -2290,12 +2290,6 @@ LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, LLVMValueRef *ConstantIndices, unsigned NumIndices); LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); -LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); -LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); -LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); -LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); -LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); -LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); @@ -2304,7 +2298,6 @@ LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); -LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, LLVMValueRef IndexConstant); LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h index 43744ba8a6178..cf3812a79f028 100644 --- a/llvm/include/llvm/IR/Constants.h +++ b/llvm/include/llvm/IR/Constants.h @@ -1041,14 +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 *getFPTrunc(Constant *C, Type *Ty, - bool OnlyIfReduced = false); - static Constant *getFPExtend(Constant *C, Type *Ty, - bool OnlyIfReduced = false); - static Constant *getUIToFP(Constant *C, Type *Ty, bool OnlyIfReduced = false); - static Constant *getSIToFP(Constant *C, Type *Ty, bool OnlyIfReduced = false); - static Constant *getFPToUI(Constant *C, Type *Ty, bool OnlyIfReduced = false); - static Constant *getFPToSI(Constant *C, Type *Ty, bool OnlyIfReduced = false); static Constant *getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced = false); static Constant *getIntToPtr(Constant *C, Type *Ty, @@ -1158,11 +1150,6 @@ class ConstantExpr : public Constant { Type *Ty ///< The type to bitcast or addrspacecast C to ); - /// 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 - ); - /// Return true if this is a convert constant expression bool isCast() const; diff --git a/llvm/include/llvm/IR/PatternMatch.h b/llvm/include/llvm/IR/PatternMatch.h index 2551e81b62b6d..f709a5ac52a41 100644 --- a/llvm/include/llvm/IR/PatternMatch.h +++ b/llvm/include/llvm/IR/PatternMatch.h @@ -1697,34 +1697,34 @@ m_ZExtOrSExtOrSelf(const OpTy &Op) { } template -inline CastOperator_match m_UIToFP(const OpTy &Op) { - return CastOperator_match(Op); +inline CastInst_match m_UIToFP(const OpTy &Op) { + return CastInst_match(Op); } template -inline CastOperator_match m_SIToFP(const OpTy &Op) { - return CastOperator_match(Op); +inline CastInst_match m_SIToFP(const OpTy &Op) { + return CastInst_match(Op); } template -inline CastOperator_match m_FPToUI(const OpTy &Op) { - return CastOperator_match(Op); +inline CastInst_match m_FPToUI(const OpTy &Op) { + return CastInst_match(Op); } template -inline CastOperator_match m_FPToSI(const OpTy &Op) { - return CastOperator_match(Op); +inline CastInst_match m_FPToSI(const OpTy &Op) { + return CastInst_match(Op); } template -inline CastOperator_match +inline CastInst_match m_FPTrunc(const OpTy &Op) { - return CastOperator_match(Op); + return CastInst_match(Op); } template -inline CastOperator_match m_FPExt(const OpTy &Op) { - return CastOperator_match(Op); +inline CastInst_match m_FPExt(const OpTy &Op) { + return CastInst_match(Op); } //===----------------------------------------------------------------------===// diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index d3abd16204a45..95fe5ede28a88 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -3805,14 +3805,8 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) { } case lltok::kw_trunc: - case lltok::kw_fptrunc: - case lltok::kw_fpext: case lltok::kw_bitcast: case lltok::kw_addrspacecast: - case lltok::kw_uitofp: - case lltok::kw_sitofp: - case lltok::kw_fptoui: - case lltok::kw_fptosi: case lltok::kw_inttoptr: case lltok::kw_ptrtoint: { unsigned Opc = Lex.getUIntVal(); @@ -3868,6 +3862,18 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) { 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_fptrunc: + return error(ID.Loc, "fptrunc constexprs are no longer supported"); + case lltok::kw_fpext: + return error(ID.Loc, "fpext constexprs are no longer supported"); + case lltok::kw_uitofp: + return error(ID.Loc, "uitofp constexprs are no longer supported"); + case lltok::kw_sitofp: + return error(ID.Loc, "sitofp constexprs are no longer supported"); + case lltok::kw_fptoui: + return error(ID.Loc, "fptoui constexprs are no longer supported"); + case lltok::kw_fptosi: + return error(ID.Loc, "fptosi constexprs are no longer supported"); case lltok::kw_icmp: case lltok::kw_fcmp: { unsigned PredVal, Opc = Lex.getUIntVal(); diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 16072d2efc95b..4e480691558f0 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -1968,18 +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::FPTrunc: - return getFPTrunc(C, Ty, OnlyIfReduced); - case Instruction::FPExt: - return getFPExtend(C, Ty, OnlyIfReduced); - case Instruction::UIToFP: - return getUIToFP(C, Ty, OnlyIfReduced); - case Instruction::SIToFP: - return getSIToFP(C, Ty, OnlyIfReduced); - case Instruction::FPToUI: - return getFPToUI(C, Ty, OnlyIfReduced); - case Instruction::FPToSI: - return getFPToSI(C, Ty, OnlyIfReduced); case Instruction::PtrToInt: return getPtrToInt(C, Ty, OnlyIfReduced); case Instruction::IntToPtr: @@ -2023,18 +2011,6 @@ Constant *ConstantExpr::getPointerBitCastOrAddrSpaceCast(Constant *S, return getBitCast(S, Ty); } -Constant *ConstantExpr::getFPCast(Constant *C, Type *Ty) { - assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() && - "Invalid cast"); - unsigned SrcBits = C->getType()->getScalarSizeInBits(); - unsigned DstBits = Ty->getScalarSizeInBits(); - if (SrcBits == DstBits) - return C; // Avoid a useless cast - Instruction::CastOps opcode = - (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt); - return getCast(opcode, C, Ty); -} - Constant *ConstantExpr::getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) { #ifndef NDEBUG bool fromVec = isa(C->getType()); @@ -2049,74 +2025,6 @@ Constant *ConstantExpr::getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) { return getFoldedCast(Instruction::Trunc, C, Ty, OnlyIfReduced); } -Constant *ConstantExpr::getFPTrunc(Constant *C, Type *Ty, bool OnlyIfReduced) { -#ifndef NDEBUG - bool fromVec = isa(C->getType()); - bool toVec = isa(Ty); -#endif - assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() && - C->getType()->getScalarSizeInBits() > Ty->getScalarSizeInBits()&& - "This is an illegal floating point truncation!"); - return getFoldedCast(Instruction::FPTrunc, C, Ty, OnlyIfReduced); -} - -Constant *ConstantExpr::getFPExtend(Constant *C, Type *Ty, bool OnlyIfReduced) { -#ifndef NDEBUG - bool fromVec = isa(C->getType()); - bool toVec = isa(Ty); -#endif - assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isFPOrFPVectorTy() && Ty->isFPOrFPVectorTy() && - C->getType()->getScalarSizeInBits() < Ty->getScalarSizeInBits()&& - "This is an illegal floating point extension!"); - return getFoldedCast(Instruction::FPExt, C, Ty, OnlyIfReduced); -} - -Constant *ConstantExpr::getUIToFP(Constant *C, Type *Ty, bool OnlyIfReduced) { -#ifndef NDEBUG - bool fromVec = isa(C->getType()); - bool toVec = isa(Ty); -#endif - assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isIntOrIntVectorTy() && Ty->isFPOrFPVectorTy() && - "This is an illegal uint to floating point cast!"); - return getFoldedCast(Instruction::UIToFP, C, Ty, OnlyIfReduced); -} - -Constant *ConstantExpr::getSIToFP(Constant *C, Type *Ty, bool OnlyIfReduced) { -#ifndef NDEBUG - bool fromVec = isa(C->getType()); - bool toVec = isa(Ty); -#endif - assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isIntOrIntVectorTy() && Ty->isFPOrFPVectorTy() && - "This is an illegal sint to floating point cast!"); - return getFoldedCast(Instruction::SIToFP, C, Ty, OnlyIfReduced); -} - -Constant *ConstantExpr::getFPToUI(Constant *C, Type *Ty, bool OnlyIfReduced) { -#ifndef NDEBUG - bool fromVec = isa(C->getType()); - bool toVec = isa(Ty); -#endif - assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isFPOrFPVectorTy() && Ty->isIntOrIntVectorTy() && - "This is an illegal floating point to uint cast!"); - return getFoldedCast(Instruction::FPToUI, C, Ty, OnlyIfReduced); -} - -Constant *ConstantExpr::getFPToSI(Constant *C, Type *Ty, bool OnlyIfReduced) { -#ifndef NDEBUG - bool fromVec = isa(C->getType()); - bool toVec = isa(Ty); -#endif - assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); - assert(C->getType()->isFPOrFPVectorTy() && Ty->isIntOrIntVectorTy() && - "This is an illegal floating point to sint cast!"); - return getFoldedCast(Instruction::FPToSI, C, Ty, OnlyIfReduced); -} - Constant *ConstantExpr::getPtrToInt(Constant *C, Type *DstTy, bool OnlyIfReduced) { assert(C->getType()->isPtrOrPtrVectorTy() && @@ -2292,14 +2200,14 @@ 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: + return false; + case Instruction::Trunc: case Instruction::PtrToInt: case Instruction::IntToPtr: case Instruction::BitCast: diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 076d1089582fe..004b0e8577a7e 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -1744,36 +1744,6 @@ LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { unwrap(ToType))); } -LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getFPTrunc(unwrap(ConstantVal), - unwrap(ToType))); -} - -LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getFPExtend(unwrap(ConstantVal), - unwrap(ToType))); -} - -LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getUIToFP(unwrap(ConstantVal), - unwrap(ToType))); -} - -LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getSIToFP(unwrap(ConstantVal), - unwrap(ToType))); -} - -LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getFPToUI(unwrap(ConstantVal), - unwrap(ToType))); -} - -LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getFPToSI(unwrap(ConstantVal), - unwrap(ToType))); -} - LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { return wrap(ConstantExpr::getPtrToInt(unwrap(ConstantVal), unwrap(ToType))); @@ -1807,11 +1777,6 @@ LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, unwrap(ToType))); } -LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { - return wrap(ConstantExpr::getFPCast(unwrap(ConstantVal), - unwrap(ToType))); -} - LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, LLVMValueRef IndexConstant) { return wrap(ConstantExpr::getExtractElement(unwrap(VectorConstant), diff --git a/llvm/test/Bindings/OCaml/core.ml b/llvm/test/Bindings/OCaml/core.ml index 523d327f69eff..909be2c8cd4c5 100644 --- a/llvm/test/Bindings/OCaml/core.ml +++ b/llvm/test/Bindings/OCaml/core.ml @@ -292,12 +292,6 @@ let test_constants () = group "constant casts"; (* CHECK: const_trunc{{.*}}trunc - * CHECK: const_fptrunc{{.*}}fptrunc - * CHECK: const_fpext{{.*}}fpext - * CHECK: const_uitofp{{.*}}uitofp - * CHECK: const_sitofp{{.*}}sitofp - * CHECK: const_fptoui{{.*}}fptoui - * CHECK: const_fptosi{{.*}}fptosi * CHECK: const_ptrtoint{{.*}}ptrtoint * CHECK: const_inttoptr{{.*}}inttoptr * CHECK: const_bitcast{{.*}}bitcast @@ -305,12 +299,6 @@ let test_constants () = 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_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); - ignore (define_global "const_sitofp" (const_sitofp foldbomb double_type) m); - ignore (define_global "const_fptoui" (const_fptoui ffoldbomb i32_type) m); - ignore (define_global "const_fptosi" (const_fptosi ffoldbomb i32_type) m); ignore (define_global "const_ptrtoint" (const_ptrtoint (const_gep i8_type (const_null (pointer_type context)) [| const_int i32_type 1 |]) diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-constantexpr.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-constantexpr.ll index 5b09e5ba2b6f0..c7870d98d4ca1 100644 --- a/llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-constantexpr.ll +++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-constantexpr.ll @@ -16,24 +16,3 @@ define i32 @test() { ; CHECK-NEXT: SI_RETURN implicit $vgpr0 ret i32 bitcast (<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 - -define i32 @test_fcmp_constexpr() { - ; CHECK-LABEL: name: test_fcmp_constexpr - ; CHECK: bb.1.entry: - ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @a - ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 4 - ; CHECK-NEXT: [[PTR_ADD:%[0-9]+]]:_(p0) = nuw G_PTR_ADD [[GV]], [[C]](s64) - ; CHECK-NEXT: [[GV1:%[0-9]+]]:_(p0) = G_GLOBAL_VALUE @var - ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[PTR_ADD]](p0), [[GV1]] - ; CHECK-NEXT: [[UITOFP:%[0-9]+]]:_(s32) = G_UITOFP [[ICMP]](s1) - ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_FCONSTANT float 0.000000e+00 - ; CHECK-NEXT: [[FCMP:%[0-9]+]]:_(s1) = G_FCMP floatpred(oeq), [[UITOFP]](s32), [[C1]] - ; CHECK-NEXT: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[FCMP]](s1) - ; CHECK-NEXT: $vgpr0 = COPY [[ZEXT]](s32) - ; CHECK-NEXT: SI_RETURN implicit $vgpr0 -entry: - %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/Generic/pr24662.ll b/llvm/test/CodeGen/Generic/pr24662.ll index 553864858a6bf..f2699a951bcc0 100644 --- a/llvm/test/CodeGen/Generic/pr24662.ll +++ b/llvm/test/CodeGen/Generic/pr24662.ll @@ -4,10 +4,6 @@ ; NVPTX failed to lower i670010, as size > 64 ; UNSUPPORTED: target=nvptx{{.*}} -define i60 @PR24662a() { - ret i60 trunc (i670010 fptoui(float 0x400D9999A0000000 to i670010) to i60) -} - define i60 @PR24662b() { %1 = fptoui float 0x400D9999A0000000 to i670010 %2 = trunc i670010 %1 to i60 diff --git a/llvm/test/Feature/vector-cast-constant-exprs.ll b/llvm/test/Feature/vector-cast-constant-exprs.ll index c81b7aace7fc0..3a9d5525c43aa 100644 --- a/llvm/test/Feature/vector-cast-constant-exprs.ll +++ b/llvm/test/Feature/vector-cast-constant-exprs.ll @@ -1,31 +1,65 @@ -; RUN: llvm-as < %s | llvm-dis | not grep "ret.*(" +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3 +; RUN: opt -S -passes=instsimplify < %s | FileCheck %s ; All of these constant expressions should fold. define <2 x float> @ga() { - ret <2 x float> fptrunc (<2 x double> to <2 x float>) +; CHECK-LABEL: define <2 x float> @ga() { +; CHECK-NEXT: ret <2 x float> +; + %fptrunc = fptrunc <2 x double> to <2 x float> + ret <2 x float> %fptrunc } define <2 x double> @gb() { - ret <2 x double> fpext (<2 x float> to <2 x double>) +; CHECK-LABEL: define <2 x double> @gb() { +; CHECK-NEXT: ret <2 x double> +; + %fpext = fpext <2 x float> to <2 x double> + ret <2 x double> %fpext } define <2 x i32> @gf() { +; CHECK-LABEL: define <2 x i32> @gf() { +; CHECK-NEXT: ret <2 x i32> +; ret <2 x i32> trunc (<2 x i64> to <2 x i32>) } define <2 x i32> @gh() { - ret <2 x i32> fptoui (<2 x float> to <2 x i32>) +; CHECK-LABEL: define <2 x i32> @gh() { +; CHECK-NEXT: ret <2 x i32> +; + %fptoui = fptoui <2 x float> to <2 x i32> + ret <2 x i32> %fptoui } define <2 x i32> @gi() { - ret <2 x i32> fptosi (<2 x float> to <2 x i32>) +; CHECK-LABEL: define <2 x i32> @gi() { +; CHECK-NEXT: ret <2 x i32> +; + %fptosi = fptosi <2 x float> to <2 x i32> + ret <2 x i32> %fptosi } define <2 x float> @gj() { - ret <2 x float> uitofp (<2 x i32> to <2 x float>) +; CHECK-LABEL: define <2 x float> @gj() { +; CHECK-NEXT: ret <2 x float> +; + %uitofp = uitofp <2 x i32> to <2 x float> + ret <2 x float> %uitofp } define <2 x float> @gk() { - ret <2 x float> sitofp (<2 x i32> to <2 x float>) +; CHECK-LABEL: define <2 x float> @gk() { +; CHECK-NEXT: ret <2 x float> +; + %sitofp = sitofp <2 x i32> to <2 x float> + ret <2 x float> %sitofp } define <2 x double> @gl() { +; CHECK-LABEL: define <2 x double> @gl() { +; CHECK-NEXT: ret <2 x double> +; ret <2 x double> bitcast (<2 x double> to <2 x double>) } define <2 x double> @gm() { +; CHECK-LABEL: define <2 x double> @gm() { +; CHECK-NEXT: ret <2 x double> +; ret <2 x double> bitcast (<2 x i64> to <2 x double>) } diff --git a/llvm/test/Integer/constexpr_bt.ll b/llvm/test/Integer/constexpr_bt.ll index dc56bc0587a60..ae0429b46fe73 100644 --- a/llvm/test/Integer/constexpr_bt.ll +++ b/llvm/test/Integer/constexpr_bt.ll @@ -21,7 +21,6 @@ @t5 = global i33** @t3 ;; Reference to a previous cast @t6 = global i33*** @t4 @t7 = global float* inttoptr (i32 12345678 to float*) ;; Cast ordinary value to ptr -@t9 = global i33 fptosi (float sitofp (i33 8 to float) to i33) ;; Nested cast expression @2 = global i32* bitcast (float* @4 to i32*) ;; Forward numeric reference diff --git a/llvm/test/Integer/fold-fpcast_bt.ll b/llvm/test/Integer/fold-fpcast_bt.ll index 0ce776dbf8511..66d0fca268b3b 100644 --- a/llvm/test/Integer/fold-fpcast_bt.ll +++ b/llvm/test/Integer/fold-fpcast_bt.ll @@ -1,34 +1,62 @@ -; RUN: llvm-as < %s | llvm-dis | FileCheck %s -; CHECK-NOT: bitcast +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3 +; RUN: opt -S -passes=instsimplify < %s | FileCheck %s define i60 @test1() { - ret i60 fptoui(float 0x400D9999A0000000 to i60) +; CHECK-LABEL: define i60 @test1() { +; CHECK-NEXT: ret i60 3 +; + %fptoui = fptoui float 0x400D9999A0000000 to i60 + ret i60 %fptoui } define float @test2() { - ret float uitofp(i60 17 to float) +; CHECK-LABEL: define float @test2() { +; CHECK-NEXT: ret float 1.700000e+01 +; + %uitofp = uitofp i60 17 to float + ret float %uitofp } define i64 @test3() { +; CHECK-LABEL: define i64 @test3() { +; CHECK-NEXT: ret i64 4614256656431372362 +; ret i64 bitcast (double 0x400921FB4D12D84A to i64) } define double @test4() { +; CHECK-LABEL: define double @test4() { +; CHECK-NEXT: ret double 2.075080e-322 +; ret double bitcast (i64 42 to double) } define i30 @test5() { - ret i30 fptoui(float 0x400D9999A0000000 to i30) +; CHECK-LABEL: define i30 @test5() { +; CHECK-NEXT: ret i30 3 +; + %fptoui = fptoui float 0x400D9999A0000000 to i30 + ret i30 %fptoui } define float @test6() { - ret float uitofp(i30 17 to float) +; CHECK-LABEL: define float @test6() { +; CHECK-NEXT: ret float 1.700000e+01 +; + %uitofp = uitofp i30 17 to float + ret float %uitofp } define i64 @test7() { +; CHECK-LABEL: define i64 @test7() { +; CHECK-NEXT: ret i64 4614256656431372362 +; ret i64 bitcast (double 0x400921FB4D12D84A to i64) } define double @test8() { +; CHECK-LABEL: define double @test8() { +; CHECK-NEXT: ret double 2.075080e-322 +; ret double bitcast (i64 42 to double) } diff --git a/llvm/test/Transforms/InstCombine/pr33453.ll b/llvm/test/Transforms/InstCombine/pr33453.ll index 7205033649d30..09f1569bc95e6 100644 --- a/llvm/test/Transforms/InstCombine/pr33453.ll +++ b/llvm/test/Transforms/InstCombine/pr33453.ll @@ -6,10 +6,14 @@ define float @patatino() { ; CHECK-LABEL: @patatino( -; CHECK-NEXT: [[FMUL:%.*]] = fmul float uitofp (i1 icmp eq (ptr getelementptr inbounds (i16, ptr @g2, i64 1), ptr @g1) to float), uitofp (i1 icmp eq (ptr getelementptr inbounds (i16, ptr @g2, i64 1), ptr @g1) to float) +; CHECK-NEXT: [[UITOFP1:%.*]] = uitofp i1 icmp eq (ptr getelementptr inbounds (i16, ptr @g2, i64 1), ptr @g1) to float +; CHECK-NEXT: [[UITOFP2:%.*]] = uitofp i1 icmp eq (ptr getelementptr inbounds (i16, ptr @g2, i64 1), ptr @g1) to float +; CHECK-NEXT: [[FMUL:%.*]] = fmul float [[UITOFP1]], [[UITOFP2]] ; CHECK-NEXT: ret float [[FMUL]] ; - %fmul = fmul float uitofp (i1 icmp eq (ptr getelementptr inbounds (i16, ptr @g2, i64 1), ptr @g1) to float), uitofp (i1 icmp eq (ptr getelementptr inbounds (i16, ptr @g2, i64 1), ptr @g1) to float) + %uitofp1 = uitofp i1 icmp eq (ptr getelementptr inbounds (i16, ptr @g2, i64 1), ptr @g1) to float + %uitofp2 = uitofp i1 icmp eq (ptr getelementptr inbounds (i16, ptr @g2, i64 1), ptr @g1) to float + %fmul = fmul float %uitofp1, %uitofp2 %call = call float @fabsf(float %fmul) ret float %call } diff --git a/llvm/test/Transforms/InstSimplify/ConstProp/constant-expr.ll b/llvm/test/Transforms/InstSimplify/ConstProp/constant-expr.ll index f46f88901de7c..8c94af39fdf72 100644 --- a/llvm/test/Transforms/InstSimplify/ConstProp/constant-expr.ll +++ b/llvm/test/Transforms/InstSimplify/ConstProp/constant-expr.ll @@ -32,18 +32,6 @@ @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>) -; CHECK: pr9011_4 = constant <4 x float> zeroinitializer -@pr9011_5 = constant <4 x float> sitofp (<4 x i8> zeroinitializer to <4 x float>) -; CHECK: pr9011_5 = constant <4 x float> zeroinitializer -@pr9011_6 = constant <4 x i32> fptosi (<4 x float> zeroinitializer to <4 x i32>) -; CHECK: pr9011_6 = constant <4 x i32> zeroinitializer -@pr9011_7 = constant <4 x i32> fptoui (<4 x float> zeroinitializer to <4 x i32>) -; CHECK: pr9011_7 = constant <4 x i32> zeroinitializer -@pr9011_8 = constant <4 x float> fptrunc (<4 x double> zeroinitializer to <4 x float>) -; CHECK: pr9011_8 = constant <4 x float> zeroinitializer -@pr9011_9 = constant <4 x double> fpext (<4 x float> zeroinitializer to <4 x double>) -; CHECK: pr9011_9 = constant <4 x double> zeroinitializer @pr9011_10 = constant <4 x double> bitcast (i256 0 to <4 x double>) ; CHECK: pr9011_10 = constant <4 x double> zeroinitializer diff --git a/llvm/unittests/IR/ConstantsTest.cpp b/llvm/unittests/IR/ConstantsTest.cpp index 158c0fe928ce7..cbe210d47de01 100644 --- a/llvm/unittests/IR/ConstantsTest.cpp +++ b/llvm/unittests/IR/ConstantsTest.cpp @@ -115,16 +115,6 @@ TEST(ConstantsTest, IntSigns) { EXPECT_EQ(0x3b, ConstantInt::get(Int8Ty, 0x13b)->getSExtValue()); } -TEST(ConstantsTest, FP128Test) { - LLVMContext Context; - Type *FP128Ty = Type::getFP128Ty(Context); - - IntegerType *Int128Ty = Type::getIntNTy(Context, 128); - Constant *Zero128 = Constant::getNullValue(Int128Ty); - Constant *X = ConstantExpr::getUIToFP(Zero128, FP128Ty); - EXPECT_TRUE(isa(X)); -} - TEST(ConstantsTest, PointerCast) { LLVMContext C; Type *PtrTy = PointerType::get(C, 0); @@ -201,8 +191,6 @@ TEST(ConstantsTest, AsInstructionsTest) { Type *Int64Ty = Type::getInt64Ty(Context); Type *Int32Ty = Type::getInt32Ty(Context); Type *Int16Ty = Type::getInt16Ty(Context); - Type *FloatTy = Type::getFloatTy(Context); - Type *DoubleTy = Type::getDoubleTy(Context); Constant *Global = M->getOrInsertGlobal("dummy", PointerType::getUnqual(Int32Ty)); @@ -210,10 +198,7 @@ TEST(ConstantsTest, AsInstructionsTest) { M->getOrInsertGlobal("dummy2", PointerType::getUnqual(Int32Ty)); Constant *P0 = ConstantExpr::getPtrToInt(Global, Int32Ty); - Constant *P1 = ConstantExpr::getUIToFP(P0, FloatTy); - Constant *P2 = ConstantExpr::getUIToFP(P0, DoubleTy); Constant *P4 = ConstantExpr::getPtrToInt(Global2, Int32Ty); - Constant *P5 = ConstantExpr::getUIToFP(P4, FloatTy); Constant *P6 = ConstantExpr::getBitCast(P4, FixedVectorType::get(Int16Ty, 2)); Constant *One = ConstantInt::get(Int32Ty, 1); @@ -225,11 +210,8 @@ TEST(ConstantsTest, AsInstructionsTest) { Constant *PoisonV16 = PoisonValue::get(P6->getType()); #define P0STR "ptrtoint (ptr @dummy to i32)" -#define P1STR "uitofp (i32 ptrtoint (ptr @dummy to i32) to float)" -#define P2STR "uitofp (i32 ptrtoint (ptr @dummy to i32) to double)" #define P3STR "ptrtoint (ptr @dummy to i1)" #define P4STR "ptrtoint (ptr @dummy2 to i32)" -#define P5STR "uitofp (i32 ptrtoint (ptr @dummy2 to i32) to float)" #define P6STR "bitcast (i32 ptrtoint (ptr @dummy2 to i32) to <2 x i16>)" CHECK(ConstantExpr::getNeg(P0), "sub i32 0, " P0STR); @@ -253,15 +235,8 @@ TEST(ConstantsTest, AsInstructionsTest) { CHECK(ConstantExpr::getAShr(P0, P0, true), "ashr exact i32 " P0STR ", " P0STR); - CHECK(ConstantExpr::getFPTrunc(P2, FloatTy), - "fptrunc double " P2STR " to float"); - CHECK(ConstantExpr::getFPExtend(P1, DoubleTy), - "fpext float " P1STR " to double"); - CHECK(ConstantExpr::getICmp(CmpInst::ICMP_EQ, P0, P4), "icmp eq i32 " P0STR ", " P4STR); - CHECK(ConstantExpr::getFCmp(CmpInst::FCMP_ULT, P1, P5), - "fcmp ult float " P1STR ", " P5STR); std::vector V; V.push_back(One);