1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
\r
2 ; RUN: opt < %s -instsimplify -S | FileCheck %s
\r
4 ; Test constant fold of constant expression GEP used by ptrtoint (the
\r
5 ; "offsetof-like expression" case).
\r
6 ; This used to hit an assert due to not supporting vectors in
\r
7 ; llvm::ConstantFoldCastInstruction when handling ptrtoint.
\r
8 define <2 x i16> @test1() {
\r
9 ; CHECK-LABEL: @test1(
\r
10 ; CHECK-NEXT: entry:
\r
11 ; 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> <i64 5, i64 7>) to <2 x i16>)
\r
14 %gep = getelementptr inbounds [10 x i32], [10 x i32]* null, i16 0, <2 x i16> <i16 5, i16 7>
\r
15 %vec = ptrtoint <2 x i32*> %gep to <2 x i16>
\r
19 ; Test constant fold of constant expression GEP used by ptrtoint (the
\r
20 ; "sizeof-like expression" case).
\r
21 ; This used to hit an assert due to not supporting vectors in
\r
22 ; llvm::ConstantFoldCastInstruction when handling ptrtoint.
\r
23 define <2 x i16> @test2() {
\r
24 ; CHECK-LABEL: @test2(
\r
25 ; CHECK-NEXT: entry:
\r
26 ; CHECK-NEXT: ret <2 x i16> ptrtoint (<2 x i32*> getelementptr (i32, i32* null, <2 x i64> <i64 5, i64 7>) to <2 x i16>)
\r
29 %gep = getelementptr i32, i32* null, <2 x i16> <i16 5, i16 7>
\r
30 %vec = ptrtoint <2 x i32*> %gep to <2 x i16>
\r