1486ed885SArthur Eubanks; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2b280ee1dSBjorn Pettersson; RUN: opt < %s -passes=instsimplify -S | FileCheck %s 3486ed885SArthur Eubanks 4486ed885SArthur Eubanks; Test constant fold of constant expression GEP used by ptrtoint (the 5486ed885SArthur Eubanks; "offsetof-like expression" case). 6486ed885SArthur Eubanks; This used to hit an assert due to not supporting vectors in 7486ed885SArthur Eubanks; llvm::ConstantFoldCastInstruction when handling ptrtoint. 8486ed885SArthur Eubanksdefine <2 x i16> @test1() { 9486ed885SArthur Eubanks; CHECK-LABEL: @test1( 10486ed885SArthur Eubanks; CHECK-NEXT: entry: 11*475f30dfSNikita Popov; CHECK-NEXT: ret <2 x i16> ptrtoint (<2 x ptr> getelementptr inbounds ([10 x i32], ptr null, <2 x i64> zeroinitializer, <2 x i64> <i64 5, i64 7>) to <2 x i16>) 12486ed885SArthur Eubanks; 13486ed885SArthur Eubanksentry: 1404b944e2SNikita Popov %gep = getelementptr inbounds [10 x i32], ptr null, i16 0, <2 x i16> <i16 5, i16 7> 1504b944e2SNikita Popov %vec = ptrtoint <2 x ptr> %gep to <2 x i16> 16486ed885SArthur Eubanks ret <2 x i16> %vec 17486ed885SArthur Eubanks} 18486ed885SArthur Eubanks 19486ed885SArthur Eubanks; Test constant fold of constant expression GEP used by ptrtoint (the 20486ed885SArthur Eubanks; "sizeof-like expression" case). 21486ed885SArthur Eubanks; This used to hit an assert due to not supporting vectors in 22486ed885SArthur Eubanks; llvm::ConstantFoldCastInstruction when handling ptrtoint. 23486ed885SArthur Eubanksdefine <2 x i16> @test2() { 24486ed885SArthur Eubanks; CHECK-LABEL: @test2( 25486ed885SArthur Eubanks; CHECK-NEXT: entry: 2604b944e2SNikita Popov; CHECK-NEXT: ret <2 x i16> ptrtoint (<2 x ptr> getelementptr (i32, ptr null, <2 x i64> <i64 5, i64 7>) to <2 x i16>) 27486ed885SArthur Eubanks; 28486ed885SArthur Eubanksentry: 2904b944e2SNikita Popov %gep = getelementptr i32, ptr null, <2 x i16> <i16 5, i16 7> 3004b944e2SNikita Popov %vec = ptrtoint <2 x ptr> %gep to <2 x i16> 31486ed885SArthur Eubanks ret <2 x i16> %vec 32486ed885SArthur Eubanks} 33