diff --git a/llvm/bindings/ocaml/llvm/llvm.ml b/llvm/bindings/ocaml/llvm/llvm.ml index 6962dce737d2..77de9a6e46fa 100644 --- a/llvm/bindings/ocaml/llvm/llvm.ml +++ b/llvm/bindings/ocaml/llvm/llvm.ml @@ -685,8 +685,6 @@ external const_pointercast : llvalue -> lltype -> llvalue external const_intcast : llvalue -> lltype -> is_signed:bool -> llvalue = "llvm_const_intcast" external const_fpcast : llvalue -> lltype -> llvalue = "llvm_const_fpcast" -external const_select : llvalue -> llvalue -> llvalue -> llvalue - = "llvm_const_select" 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 59ac5b855130..9c8b3b883e14 100644 --- a/llvm/bindings/ocaml/llvm/llvm.mli +++ b/llvm/bindings/ocaml/llvm/llvm.mli @@ -1268,11 +1268,6 @@ val const_intcast : llvalue -> lltype -> is_signed:bool -> llvalue See the method [llvm::ConstantExpr::getFPCast]. *) val const_fpcast : llvalue -> lltype -> llvalue -(** [const_select cond t f] returns the constant conditional which returns value - [t] if the boolean constant [cond] is true and the value [f] otherwise. - See the method [llvm::ConstantExpr::getSelect]. *) -val const_select : llvalue -> llvalue -> llvalue -> 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 a9d25751fd2c..0154b2f49c25 100644 --- a/llvm/bindings/ocaml/llvm/llvm_ocaml.c +++ b/llvm/bindings/ocaml/llvm/llvm_ocaml.c @@ -1385,13 +1385,6 @@ value llvm_const_fpcast(value CV, value T) { return to_val(Value); } -/* llvalue -> llvalue -> llvalue -> llvalue */ -value llvm_const_select(value Cond, value IfTrue, value IfFalse) { - LLVMValueRef Value = - LLVMConstSelect(Value_val(Cond), Value_val(IfTrue), Value_val(IfFalse)); - 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/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst index 4cf01ad8e284..56da5be434eb 100644 --- a/llvm/docs/ReleaseNotes.rst +++ b/llvm/docs/ReleaseNotes.rst @@ -56,6 +56,11 @@ Changes to the LLVM IR * The ``nofpclass`` attribute was introduced. This allows more optimizations around special floating point value comparisons. +* The constant expression variants of the following instructions have been + removed: + + * ``select`` + Changes to building LLVM ------------------------ @@ -151,6 +156,12 @@ Changes to the C API These belonged to the no longer supported legacy pass manager. * As part of the opaque pointer transition, ``LLVMGetElementType`` no longer gives the pointee type of a pointer type. +* The following functions for creating constant expressions have been removed, + because the underlying constant expressions are no longer supported. Instead, + an instruction should be created using the ``LLVMBuildXYZ`` APIs, which will + constant fold the operands if possible and create an instruction otherwise: + + * ``LLVMConstSelect`` Changes to the FastISel infrastructure -------------------------------------- diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h index 5454cc2d96c5..f2959ac8d22d 100644 --- a/llvm/include/llvm-c/Core.h +++ b/llvm/include/llvm-c/Core.h @@ -2257,9 +2257,6 @@ LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType, LLVMBool isSigned); LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); -LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition, - LLVMValueRef ConstantIfTrue, - LLVMValueRef ConstantIfFalse); 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 e82c6a8e1eab..13d5fb218bed 100644 --- a/llvm/include/llvm/IR/Constants.h +++ b/llvm/include/llvm/IR/Constants.h @@ -1208,12 +1208,6 @@ public: /// Return true if this is a compare constant expression bool isCompare() const; - /// Select constant expr - /// - /// \param OnlyIfReducedTy see \a getWithOperands() docs. - static Constant *getSelect(Constant *C, Constant *V1, Constant *V2, - Type *OnlyIfReducedTy = nullptr); - /// get - Return a binary or shift operator constant expression, /// folding if possible. /// diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 8b8ba4107e71..8ee1b665c9b7 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -3882,6 +3882,8 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) { return error(ID.Loc, "frem constexprs are no longer supported"); case lltok::kw_fneg: 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_icmp: case lltok::kw_fcmp: { unsigned PredVal, Opc = Lex.getUIntVal(); @@ -4011,8 +4013,7 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) { case lltok::kw_getelementptr: case lltok::kw_shufflevector: case lltok::kw_insertelement: - case lltok::kw_extractelement: - case lltok::kw_select: { + case lltok::kw_extractelement: { unsigned Opc = Lex.getUIntVal(); SmallVector Elts; bool InBounds = false; @@ -4091,13 +4092,6 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) { ID.ConstantVal = ConstantExpr::getGetElementPtr(Ty, Elts[0], Indices, InBounds, InRangeOp); - } else if (Opc == Instruction::Select) { - if (Elts.size() != 3) - return error(ID.Loc, "expected three operands to select"); - if (const char *Reason = SelectInst::areInvalidOperands(Elts[0], Elts[1], - Elts[2])) - return error(ID.Loc, Reason); - ID.ConstantVal = ConstantExpr::getSelect(Elts[0], Elts[1], Elts[2]); } else if (Opc == Instruction::ShuffleVector) { if (Elts.size() != 3) return error(ID.Loc, "expected three operands to shufflevector"); diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index dd75542164d3..64616240d4a3 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1417,7 +1417,13 @@ static bool isConstExprSupported(const BitcodeConstant *BC) { if (Opcode == Instruction::GetElementPtr) return ConstantExpr::isSupportedGetElementPtr(BC->SrcElemTy); - return Opcode != Instruction::FNeg; + switch (Opcode) { + case Instruction::FNeg: + case Instruction::Select: + return false; + default: + return true; + } } Expected BitcodeReader::materializeValue(unsigned StartValID, @@ -1549,9 +1555,6 @@ Expected BitcodeReader::materializeValue(unsigned StartValID, ArrayRef(ConstOps).drop_front(), BC->Flags, BC->getInRangeIndex()); break; - case Instruction::Select: - C = ConstantExpr::getSelect(ConstOps[0], ConstOps[1], ConstOps[2]); - break; case Instruction::ExtractElement: C = ConstantExpr::getExtractElement(ConstOps[0], ConstOps[1]); break; diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 51756eb8ecb0..a368ac303bd9 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -2676,12 +2676,6 @@ void ModuleBitcodeWriter::writeConstants(unsigned FirstVal, unsigned LastVal, } break; } - case Instruction::Select: - Code = bitc::CST_CODE_CE_SELECT; - Record.push_back(VE.getValueID(C->getOperand(0))); - Record.push_back(VE.getValueID(C->getOperand(1))); - Record.push_back(VE.getValueID(C->getOperand(2))); - break; case Instruction::ExtractElement: Code = bitc::CST_CODE_CE_EXTRACTELT; Record.push_back(VE.getTypeID(C->getOperand(0)->getType())); diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 553bc1e277e3..59131a4264fc 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -593,17 +593,6 @@ Constant *llvm::ConstantFoldSelectInstruction(Constant *Cond, if (isa(V1) && NotPoison(V2)) return V2; if (isa(V2) && NotPoison(V1)) return V1; - if (ConstantExpr *TrueVal = dyn_cast(V1)) { - if (TrueVal->getOpcode() == Instruction::Select) - if (TrueVal->getOperand(0) == Cond) - return ConstantExpr::getSelect(Cond, TrueVal->getOperand(1), V2); - } - if (ConstantExpr *FalseVal = dyn_cast(V2)) { - if (FalseVal->getOpcode() == Instruction::Select) - if (FalseVal->getOperand(0) == Cond) - return ConstantExpr::getSelect(Cond, V1, FalseVal->getOperand(2)); - } - return nullptr; } diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index 9348d1af65a4..51ad3a12c488 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -547,8 +547,6 @@ void llvm::deleteConstant(Constant *C) { delete static_cast(C); else if (isa(C)) delete static_cast(C); - else if (isa(C)) - delete static_cast(C); else if (isa(C)) delete static_cast(C); else if (isa(C)) @@ -1488,8 +1486,6 @@ Constant *ConstantExpr::getWithOperands(ArrayRef Ops, Type *Ty, case Instruction::BitCast: case Instruction::AddrSpaceCast: return ConstantExpr::getCast(getOpcode(), Ops[0], Ty, OnlyIfReduced); - case Instruction::Select: - return ConstantExpr::getSelect(Ops[0], Ops[1], Ops[2], OnlyIfReducedTy); case Instruction::InsertElement: return ConstantExpr::getInsertElement(Ops[0], Ops[1], Ops[2], OnlyIfReducedTy); @@ -2441,23 +2437,6 @@ Constant *ConstantExpr::getCompare(unsigned short Predicate, Constant *C1, } } -Constant *ConstantExpr::getSelect(Constant *C, Constant *V1, Constant *V2, - Type *OnlyIfReducedTy) { - assert(!SelectInst::areInvalidOperands(C, V1, V2)&&"Invalid select operands"); - - if (Constant *SC = ConstantFoldSelectInstruction(C, V1, V2)) - return SC; // Fold common cases - - if (OnlyIfReducedTy == V1->getType()) - return nullptr; - - Constant *ArgVec[] = { C, V1, V2 }; - ConstantExprKeyType Key(Instruction::Select, ArgVec); - - LLVMContextImpl *pImpl = C->getContext().pImpl; - return pImpl->ExprConstants.getOrCreate(V1->getType(), Key); -} - Constant *ConstantExpr::getGetElementPtr(Type *Ty, Constant *C, ArrayRef Idxs, bool InBounds, std::optional InRangeIndex, @@ -3439,8 +3418,6 @@ Instruction *ConstantExpr::getAsInstruction(Instruction *InsertBefore) const { case Instruction::AddrSpaceCast: return CastInst::Create((Instruction::CastOps)getOpcode(), Ops[0], getType(), "", InsertBefore); - case Instruction::Select: - return SelectInst::Create(Ops[0], Ops[1], Ops[2], "", InsertBefore); case Instruction::InsertElement: return InsertElementInst::Create(Ops[0], Ops[1], Ops[2], "", InsertBefore); case Instruction::ExtractElement: diff --git a/llvm/lib/IR/ConstantsContext.h b/llvm/lib/IR/ConstantsContext.h index fbda443de7b2..6023216a5070 100644 --- a/llvm/lib/IR/ConstantsContext.h +++ b/llvm/lib/IR/ConstantsContext.h @@ -90,32 +90,6 @@ public: } }; -/// SelectConstantExpr - This class is private to Constants.cpp, and is used -/// behind the scenes to implement select constant exprs. -class SelectConstantExpr final : public ConstantExpr { -public: - SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3) - : ConstantExpr(C2->getType(), Instruction::Select, &Op<0>(), 3) { - Op<0>() = C1; - Op<1>() = C2; - Op<2>() = C3; - } - - // allocate space for exactly three operands - void *operator new(size_t S) { return User::operator new(S, 3); } - void operator delete(void *Ptr) { User::operator delete(Ptr); } - - /// Transparently provide more efficient getOperand methods. - DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); - - static bool classof(const ConstantExpr *CE) { - return CE->getOpcode() == Instruction::Select; - } - static bool classof(const Value *V) { - return isa(V) && classof(cast(V)); - } -}; - /// ExtractElementConstantExpr - This class is private to /// Constants.cpp, and is used behind the scenes to implement /// extractelement constant exprs. @@ -279,11 +253,6 @@ struct OperandTraits : public FixedNumOperandTraits {}; DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BinaryConstantExpr, Value) -template <> -struct OperandTraits - : public FixedNumOperandTraits {}; -DEFINE_TRANSPARENT_OPERAND_ACCESSORS(SelectConstantExpr, Value) - template <> struct OperandTraits : public FixedNumOperandTraits {}; @@ -523,8 +492,6 @@ public: return new BinaryConstantExpr(Opcode, Ops[0], Ops[1], SubclassOptionalData); llvm_unreachable("Invalid ConstantExpr!"); - case Instruction::Select: - return new SelectConstantExpr(Ops[0], Ops[1], Ops[2]); case Instruction::ExtractElement: return new ExtractElementConstantExpr(Ops[0], Ops[1]); case Instruction::InsertElement: diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 85b7d17ef56c..283296b639ff 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -1799,14 +1799,6 @@ LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType) { unwrap(ToType))); } -LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition, - LLVMValueRef ConstantIfTrue, - LLVMValueRef ConstantIfFalse) { - return wrap(ConstantExpr::getSelect(unwrap(ConstantCondition), - unwrap(ConstantIfTrue), - unwrap(ConstantIfFalse))); -} - LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, LLVMValueRef IndexConstant) { return wrap(ConstantExpr::getExtractElement(unwrap(VectorConstant), diff --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp index 114738a35fd1..b6713730bfa9 100644 --- a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp +++ b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp @@ -694,18 +694,6 @@ static Value *cloneConstantExprWithNewAddressSpace( return ConstantExpr::getAddrSpaceCast(CE, TargetType); } - if (CE->getOpcode() == Instruction::Select) { - Constant *Src0 = CE->getOperand(1); - Constant *Src1 = CE->getOperand(2); - if (Src0->getType()->getPointerAddressSpace() == - Src1->getType()->getPointerAddressSpace()) { - - return ConstantExpr::getSelect( - CE->getOperand(0), ConstantExpr::getAddrSpaceCast(Src0, TargetType), - ConstantExpr::getAddrSpaceCast(Src1, TargetType)); - } - } - if (CE->getOpcode() == Instruction::IntToPtr) { assert(isNoopPtrIntCastPair(cast(CE), *DL, TTI)); Constant *Src = cast(CE->getOperand(0))->getOperand(0); diff --git a/llvm/test/Analysis/ScalarEvolution/logical-operations.ll b/llvm/test/Analysis/ScalarEvolution/logical-operations.ll index e14f47f0e15a..d557f50326d5 100644 --- a/llvm/test/Analysis/ScalarEvolution/logical-operations.ll +++ b/llvm/test/Analysis/ScalarEvolution/logical-operations.ll @@ -410,11 +410,14 @@ define ptr @select_between_constantptrs(i1 %c, ptr %x) { define ptr @tautological_select() { ; CHECK-LABEL: 'tautological_select' ; CHECK-NEXT: Classifying expressions for: @tautological_select -; CHECK-NEXT: %r = getelementptr i8, ptr @constant, i32 0 +; CHECK-NEXT: %s = select i1 true, ptr @constant, ptr @another_constant +; CHECK-NEXT: --> @constant U: [0,-3) S: [-9223372036854775808,9223372036854775805) +; CHECK-NEXT: %r = getelementptr i8, ptr %s ; CHECK-NEXT: --> @constant U: [0,-3) S: [-9223372036854775808,9223372036854775805) ; CHECK-NEXT: Determining loop execution counts for: @tautological_select ; - %r = getelementptr i8, ptr select (i1 true, ptr @constant, ptr @another_constant), i32 0 + %s = select i1 true, ptr @constant, ptr @another_constant + %r = getelementptr i8, ptr %s ret ptr %r } diff --git a/llvm/test/Assembler/ConstantExprFoldSelect.ll b/llvm/test/Assembler/ConstantExprFoldSelect.ll index 5d218a9570b9..1ece1f87c340 100644 --- a/llvm/test/Assembler/ConstantExprFoldSelect.ll +++ b/llvm/test/Assembler/ConstantExprFoldSelect.ll @@ -1,9 +1,9 @@ -; RUN: llvm-as < %s | llvm-dis | FileCheck %s +; RUN: opt -S -passes=instsimplify < %s | FileCheck %s ; RUN: verify-uselistorder %s ; PR18319 -define void @function() { - %c = trunc <4 x i16> select (<4 x i1> , <4 x i16> , <4 x i16> ) to <4 x i8> +define <4 x i16> @function() { + %s = select <4 x i1> , <4 x i16> , <4 x i16> ; CHECK: - ret void + ret <4 x i16> %s } diff --git a/llvm/test/Bindings/OCaml/core.ml b/llvm/test/Bindings/OCaml/core.ml index 33841deb42cf..d2dd52c07608 100644 --- a/llvm/test/Bindings/OCaml/core.ml +++ b/llvm/test/Bindings/OCaml/core.ml @@ -333,7 +333,6 @@ let test_constants () = group "misc constants"; (* CHECK: const_size_of{{.*}}getelementptr{{.*}}null * CHECK: const_gep{{.*}}getelementptr - * CHECK: const_select{{.*}}select * CHECK: const_extractelement{{.*}}extractelement * CHECK: const_insertelement{{.*}}insertelement * CHECK: const_shufflevector = global <4 x i32> @@ -341,10 +340,6 @@ let test_constants () = ignore (define_global "const_size_of" (size_of (pointer_type context)) m); ignore (define_global "const_gep" (const_gep i8_type foldbomb_gv [| five |]) m); - ignore (define_global "const_select" (const_select - (const_icmp Icmp.Sle foldbomb five) - (const_int i8_type (-1)) - (const_int i8_type 0)) m); let zero = const_int i32_type 0 in let one = const_int i32_type 1 in ignore (define_global "const_extractelement" (const_extractelement diff --git a/llvm/test/Bitcode/select.ll b/llvm/test/Bitcode/select.ll deleted file mode 100644 index 7e62361822a8..000000000000 --- a/llvm/test/Bitcode/select.ll +++ /dev/null @@ -1,18 +0,0 @@ -; RUN: llvm-as < %s | llvm-dis | FileCheck %s -; RUN: verify-uselistorder < %s - -define <2 x i32> @main() { - ret <2 x i32> select (<2 x i1> , <2 x i32> zeroinitializer, <2 x i32> ) -} - -; CHECK: define <2 x i32> @main() { -; CHECK: ret <2 x i32> -; CHECK: } - -define <2 x float> @f() { - ret <2 x float> select (i1 ptrtoint (<2 x float> ()* @f to i1), <2 x float> , <2 x float> zeroinitializer) -} - -; CHECK: define <2 x float> @f() { -; CHECK: ret <2 x float> select (i1 ptrtoint (ptr @f to i1), <2 x float> , <2 x float> zeroinitializer) -; CHECK: } diff --git a/llvm/test/Bitcode/thinlto-function-summary-callgraph-cast.ll b/llvm/test/Bitcode/thinlto-function-summary-callgraph-cast.ll index 1926603b8b1f..4d52edd6a085 100644 --- a/llvm/test/Bitcode/thinlto-function-summary-callgraph-cast.ll +++ b/llvm/test/Bitcode/thinlto-function-summary-callgraph-cast.ll @@ -9,7 +9,7 @@ ; "op7" is a call to "callee" function. ; CHECK-NEXT: ; "another_caller" has only references but no calls. -; CHECK-NEXT: +; CHECK-NEXT: ; CHECK-NEXT: ; CHECK-NEXT: @@ -27,7 +27,7 @@ define void @caller() { define void @another_caller() { ; Test calls that aren't handled either as direct or indirect. - call void select (i1 icmp eq (ptr @global, ptr null), ptr @f, ptr @g)() + call void getelementptr (i8, ptr @f, i64 ptrtoint (ptr @g to i64))() ret void } diff --git a/llvm/test/Bitcode/vscale-round-trip.ll b/llvm/test/Bitcode/vscale-round-trip.ll index 62a3479a3724..1962e90fa464 100644 --- a/llvm/test/Bitcode/vscale-round-trip.ll +++ b/llvm/test/Bitcode/vscale-round-trip.ll @@ -36,14 +36,14 @@ define @non_const_shufflevector( %lhs, } ; CHECK-LABEL: define @const_select() -; CHECK: select ( +; CHECK: select define @const_select() { - ret select - ( insertelement + %s = select insertelement ( undef, i1 icmp ne (i32* @important_val, i32* null), i32 0), zeroinitializer, - insertelement ( undef, i32 1, i32 0)) + insertelement ( undef, i32 1, i32 0) + ret %s } diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-constantexpr.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-constantexpr.ll index 6a0975f7fa72..9f96b1d0d719 100644 --- a/llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-constantexpr.ll +++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-constantexpr.ll @@ -20,43 +20,6 @@ define i32 @test() { ret i32 bitcast (<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) } -@gint = external addrspace(1) global i8, align 4 - -; Technically we should be able to fold away the compare to true, but -; currently constexpr doesn't understand null in non-0 address spaces. -define amdgpu_kernel void @constantexpr_select_0() { - ; CHECK-LABEL: name: constantexpr_select_0 - ; CHECK: bb.1 (%ir-block.0): - ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p1) = G_GLOBAL_VALUE @gint - ; CHECK-NEXT: [[C:%[0-9]+]]:_(p1) = G_CONSTANT i64 0 - ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[GV]](p1), [[C]] - ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 - ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 0 - ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s1), [[C1]], [[C2]] - ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(p1) = G_IMPLICIT_DEF - ; CHECK-NEXT: G_STORE [[SELECT]](s32), [[DEF]](p1) :: (store (s32) into `ptr addrspace(1) undef`, addrspace 1) - ; CHECK-NEXT: S_ENDPGM 0 - store i32 select (i1 icmp eq (ptr addrspace(1) @gint, ptr addrspace(1) null), i32 1, i32 0), ptr addrspace(1) undef, align 4 - ret void -} - -define amdgpu_kernel void @constantexpr_select_1() { - ; CHECK-LABEL: name: constantexpr_select_1 - ; CHECK: bb.1 (%ir-block.0): - ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 1024 - ; CHECK-NEXT: [[INTTOPTR:%[0-9]+]]:_(p1) = G_INTTOPTR [[C]](s64) - ; CHECK-NEXT: [[GV:%[0-9]+]]:_(p1) = G_GLOBAL_VALUE @gint - ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(s1) = G_ICMP intpred(eq), [[INTTOPTR]](p1), [[GV]] - ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 1 - ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 0 - ; CHECK-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[ICMP]](s1), [[C1]], [[C2]] - ; CHECK-NEXT: [[DEF:%[0-9]+]]:_(p1) = G_IMPLICIT_DEF - ; CHECK-NEXT: G_STORE [[SELECT]](s32), [[DEF]](p1) :: (store (s32) into `ptr addrspace(1) undef`, addrspace 1) - ; CHECK-NEXT: S_ENDPGM 0 - store i32 select (i1 icmp eq (ptr addrspace(1) @gint, ptr addrspace(1) inttoptr (i64 1024 to ptr addrspace(1))), i32 1, i32 0), ptr addrspace(1) undef, align 4 - ret void -} - @a = external global [2 x i32], align 4 define i32 @test_fcmp_constexpr() { diff --git a/llvm/test/CodeGen/Generic/pr33094.ll b/llvm/test/CodeGen/Generic/pr33094.ll index f1cf67b0ae63..cd98ec3b139b 100644 --- a/llvm/test/CodeGen/Generic/pr33094.ll +++ b/llvm/test/CodeGen/Generic/pr33094.ll @@ -12,8 +12,8 @@ @B_Inst = global %B zeroinitializer define i64 @foo() { - %e = extractvalue %Tuple select (i1 icmp eq - (ptr @A_Inst, ptr @B_Inst), - %Tuple { i64 33 }, %Tuple { i64 42 }), 0 + %s = select i1 icmp eq (ptr @A_Inst, ptr @B_Inst), + %Tuple { i64 33 }, %Tuple { i64 42 } + %e = extractvalue %Tuple %s, 0 ret i64 %e } diff --git a/llvm/test/CodeGen/PowerPC/ext-bool-trunc-repl.ll b/llvm/test/CodeGen/PowerPC/ext-bool-trunc-repl.ll index b12414e159a7..a64354222fa7 100644 --- a/llvm/test/CodeGen/PowerPC/ext-bool-trunc-repl.ll +++ b/llvm/test/CodeGen/PowerPC/ext-bool-trunc-repl.ll @@ -11,26 +11,35 @@ define void @fn2() #0 { br i1 undef, label %1, label %10 -;