xref: /aosp_15_r20/external/llvm/test/Transforms/InstCombine/2007-02-07-PointerCast.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker;RUN: opt < %s -instcombine -S | grep zext
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; Make sure the uint isn't removed.  Instcombine in llvm 1.9 was dropping the
4*9880d681SAndroid Build Coastguard Worker; uint cast which was causing a sign extend. This only affected code with
5*9880d681SAndroid Build Coastguard Worker; pointers in the high half of memory, so it wasn't noticed much
6*9880d681SAndroid Build Coastguard Worker; compile a kernel though...
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-p:32:32"
9*9880d681SAndroid Build Coastguard Worker@str = internal constant [6 x i8] c"%llx\0A\00"         ; <[6 x i8]*> [#uses=1]
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Workerdeclare i32 @printf(i8*, ...)
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Workerdefine i32 @main(i32 %x, i8** %a) {
14*9880d681SAndroid Build Coastguard Workerentry:
15*9880d681SAndroid Build Coastguard Worker        %tmp = getelementptr [6 x i8], [6 x i8]* @str, i32 0, i64 0               ; <i8*> [#uses=1]
16*9880d681SAndroid Build Coastguard Worker        %tmp1 = load i8*, i8** %a            ; <i8*> [#uses=1]
17*9880d681SAndroid Build Coastguard Worker        %tmp2 = ptrtoint i8* %tmp1 to i32               ; <i32> [#uses=1]
18*9880d681SAndroid Build Coastguard Worker        %tmp3 = zext i32 %tmp2 to i64           ; <i64> [#uses=1]
19*9880d681SAndroid Build Coastguard Worker        %tmp.upgrd.1 = call i32 (i8*, ...) @printf( i8* %tmp, i64 %tmp3 )              ; <i32> [#uses=0]
20*9880d681SAndroid Build Coastguard Worker        ret i32 0
21*9880d681SAndroid Build Coastguard Worker}
22*9880d681SAndroid Build Coastguard Worker
23