Index: lib/IR/ConstantFold.cpp =================================================================== --- lib/IR/ConstantFold.cpp +++ lib/IR/ConstantFold.cpp @@ -620,6 +620,8 @@ return ConstantPointerNull::get(cast(DestTy)); return nullptr; // Other pointer types cannot be casted case Instruction::PtrToInt: // always treated as unsigned + if (V->getType()->isVectorTy()) + return nullptr; // Is it a null pointer value? if (V->isNullValue()) return ConstantInt::get(DestTy, 0); Index: test/Analysis/ConstantFolding/cast-vector.ll =================================================================== --- /dev/null +++ test/Analysis/ConstantFolding/cast-vector.ll @@ -0,0 +1,17 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -instsimplify -S | FileCheck %s + +; The GEP is a Constant value, but the ptrtoint operand is not an isa. +; This used to crash due to not supporting vectors in llvm::ConstantFoldCastInstruction +; when handling the ptrtoint. +define <2 x i16> @test1() { +; CHECK-LABEL: @test1( +; CHECK-NEXT: entry: +; CHECK-NEXT: ret <2 x i16> ptrtoint (<2 x i32*> getelementptr ([10 x i32], [10 x i32]* null, <2 x i64> zeroinitializer, <2 x i64> ) to <2 x i16>) +; +entry: + %gep = getelementptr inbounds [10 x i32], [10 x i32]* null, i16 0, <2 x i16> + %vec = ptrtoint <2 x i32*> %gep to <2 x i16> + ret <2 x i16> %vec +} +