111b41910SDávid Bolvanský; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2b280ee1dSBjorn Pettersson; RUN: opt -S -passes=instsimplify < %s | FileCheck %s 3cee313d2SEric Christophertarget datalayout = "p:32:32" 4cee313d2SEric Christopher 5cee313d2SEric Christopherdefine i1 @test1(i1 %V) { 611b41910SDávid Bolvanský; CHECK-LABEL: @test1( 711b41910SDávid Bolvanský; CHECK-NEXT: entry: 811b41910SDávid Bolvanský; CHECK-NEXT: ret i1 [[V:%.*]] 911b41910SDávid Bolvanský; 10cee313d2SEric Christopherentry: 11cee313d2SEric Christopher %Z = zext i1 %V to i32 12cee313d2SEric Christopher %T = trunc i32 %Z to i1 13cee313d2SEric Christopher ret i1 %T 14cee313d2SEric Christopher} 15cee313d2SEric Christopher 16*04b944e2SNikita Popovdefine ptr @test2(ptr %V) { 1711b41910SDávid Bolvanský; CHECK-LABEL: @test2( 1811b41910SDávid Bolvanský; CHECK-NEXT: entry: 19*04b944e2SNikita Popov; CHECK-NEXT: ret ptr [[V:%.*]] 2011b41910SDávid Bolvanský; 21cee313d2SEric Christopherentry: 22*04b944e2SNikita Popov ret ptr %V 23cee313d2SEric Christopher} 24cee313d2SEric Christopher 25*04b944e2SNikita Popovdefine ptr @test3(ptr %V) { 2611b41910SDávid Bolvanský; CHECK-LABEL: @test3( 2711b41910SDávid Bolvanský; CHECK-NEXT: entry: 28*04b944e2SNikita Popov; CHECK-NEXT: ret ptr [[V:%.*]] 2911b41910SDávid Bolvanský; 30cee313d2SEric Christopherentry: 31*04b944e2SNikita Popov ret ptr %V 32cee313d2SEric Christopher} 33cee313d2SEric Christopher 34cee313d2SEric Christopherdefine i32 @test4() { 35cee313d2SEric Christopher; CHECK-LABEL: @test4( 3611b41910SDávid Bolvanský; CHECK-NEXT: ret i32 4 3711b41910SDávid Bolvanský; 38cee313d2SEric Christopher %alloca = alloca i32, align 4 ; alloca + 0 39*04b944e2SNikita Popov %gep = getelementptr inbounds i32, ptr %alloca, i32 1 ; alloca + 4 40*04b944e2SNikita Popov %pti = ptrtoint ptr %alloca to i32 ; alloca 41cee313d2SEric Christopher %sub = sub i32 0, %pti ; -alloca 42*04b944e2SNikita Popov %add = getelementptr [4 x i8], ptr %gep, i32 0, i32 %sub ; alloca + 4 - alloca == 4 43*04b944e2SNikita Popov %add_to_int = ptrtoint ptr %add to i32 ; 4 44cee313d2SEric Christopher ret i32 %add_to_int ; 4 45cee313d2SEric Christopher} 46cee313d2SEric Christopher 47cee313d2SEric Christopherdefine i32 @test5() { 48cee313d2SEric Christopher; CHECK-LABEL: @test5( 4911b41910SDávid Bolvanský; CHECK-NEXT: ret i32 3 5011b41910SDávid Bolvanský; 51cee313d2SEric Christopher %alloca = alloca i32, align 4 ; alloca + 0 52*04b944e2SNikita Popov %gep = getelementptr inbounds i32, ptr %alloca, i32 1 ; alloca + 4 53*04b944e2SNikita Popov %pti = ptrtoint ptr %alloca to i32 ; alloca 54cee313d2SEric Christopher %sub = xor i32 %pti, -1 ; ~alloca 55*04b944e2SNikita Popov %add = getelementptr [4 x i8], ptr %gep, i32 0, i32 %sub ; alloca + 4 - alloca - 1 == 3 56*04b944e2SNikita Popov %add_to_int = ptrtoint ptr %add to i32 ; 4 57cee313d2SEric Christopher ret i32 %add_to_int ; 4 58cee313d2SEric Christopher} 59