1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=instsimplify < %s | FileCheck %s
3 target datalayout = "p:32:32"
5 define i1 @test1(i1 %V) {
8 ; CHECK-NEXT: ret i1 [[V:%.*]]
11 %Z = zext i1 %V to i32
12 %T = trunc i32 %Z to i1
16 define ptr @test2(ptr %V) {
17 ; CHECK-LABEL: @test2(
19 ; CHECK-NEXT: ret ptr [[V:%.*]]
25 define ptr @test3(ptr %V) {
26 ; CHECK-LABEL: @test3(
28 ; CHECK-NEXT: ret ptr [[V:%.*]]
35 ; CHECK-LABEL: @test4(
36 ; CHECK-NEXT: ret i32 4
38 %alloca = alloca i32, align 4 ; alloca + 0
39 %gep = getelementptr inbounds i32, ptr %alloca, i32 1 ; alloca + 4
40 %pti = ptrtoint ptr %alloca to i32 ; alloca
41 %sub = sub i32 0, %pti ; -alloca
42 %add = getelementptr [4 x i8], ptr %gep, i32 0, i32 %sub ; alloca + 4 - alloca == 4
43 %add_to_int = ptrtoint ptr %add to i32 ; 4
44 ret i32 %add_to_int ; 4
48 ; CHECK-LABEL: @test5(
49 ; CHECK-NEXT: ret i32 3
51 %alloca = alloca i32, align 4 ; alloca + 0
52 %gep = getelementptr inbounds i32, ptr %alloca, i32 1 ; alloca + 4
53 %pti = ptrtoint ptr %alloca to i32 ; alloca
54 %sub = xor i32 %pti, -1 ; ~alloca
55 %add = getelementptr [4 x i8], ptr %gep, i32 0, i32 %sub ; alloca + 4 - alloca - 1 == 3
56 %add_to_int = ptrtoint ptr %add to i32 ; 4
57 ret i32 %add_to_int ; 4