1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -O3 -S < %s | FileCheck %s
4 ; Arg promotion eliminates the struct argument, and eliminates dead arguments, but introduces and leaves dead loads of the eliminated dead arg in callers
6 %struct.ss = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
8 define internal void @phantomLoad(ptr %p, ptr %y, ptr %x) {
15 define ptr @parent(ptr align 8 dereferenceable(72) %f, i16 %val1, i16 %val2, i32 %val3) align 2 {
16 ; CHECK-LABEL: define noundef nonnull ptr @parent
17 ; CHECK-SAME: (ptr readonly returned align 8 dereferenceable(72) [[F:%.*]], i16 [[VAL1:%.*]], i16 [[VAL2:%.*]], i32 [[VAL3:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] align 2 {
19 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds i8, ptr [[F]], i64 64
20 ; CHECK-NEXT: [[F_VAL:%.*]] = load ptr, ptr [[TMP0]], align 8
21 ; CHECK-NEXT: [[CMP_NOT_NOT_I:%.*]] = icmp eq i32 [[VAL3]], 0
22 ; CHECK-NEXT: [[SPEC_SELECT_I:%.*]] = select i1 [[CMP_NOT_NOT_I]], i16 [[VAL1]], i16 [[VAL2]]
23 ; CHECK-NEXT: [[SPEC_SELECT2_I:%.*]] = select i1 [[CMP_NOT_NOT_I]], i16 [[VAL2]], i16 [[VAL1]]
24 ; CHECK-NEXT: store i16 [[SPEC_SELECT_I]], ptr [[F_VAL]], align 2
25 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i8, ptr [[F_VAL]], i64 16
26 ; CHECK-NEXT: store i16 [[SPEC_SELECT2_I]], ptr [[TMP1]], align 2
27 ; CHECK-NEXT: ret ptr [[F]]
30 call void @badChild(ptr align 8 dereferenceable(72) %f, i16 %val1, i16 %val2, i32 %val3) #4
34 define internal void @badChild(ptr align 8 dereferenceable(72) %this, i16 %val1, i16 %val2, i32 %val3) align 2 {
36 %othergep = getelementptr inbounds %struct.ss, ptr %this, i64 0, i32 2
37 %load0 = load ptr, ptr %othergep, align 8
38 %load2 = load ptr, ptr %this
41 call void @phantomLoad(ptr %load0, ptr %x, ptr %y)
42 call void @phantomLoad(ptr %load2, ptr %x, ptr %y)
43 %cmp.not.not = icmp eq i32 %val3, 0
44 br i1 %cmp.not.not, label %if.then, label %if.else
46 if.then: ; preds = %entry
47 %0 = getelementptr inbounds %struct.ss, ptr %this, i64 0, i32 8
48 %1 = load ptr, ptr %0, align 8
49 store i16 %val1, ptr %1, align 2
50 %add.ptr.i.i.i.i = getelementptr inbounds i8, ptr %1, i64 16
51 store i16 %val2, ptr %add.ptr.i.i.i.i, align 2
54 if.else: ; preds = %entry
55 %2 = getelementptr inbounds %struct.ss, ptr %this, i64 0, i32 8
56 %3 = load ptr, ptr %2, align 8
57 %add.ptr.i.i.i.i7 = getelementptr inbounds i8, ptr %3, i64 16
58 store i16 %val1, ptr %add.ptr.i.i.i.i7, align 2
59 store i16 %val2, ptr %3, align 2
62 if.end: ; preds = %if.else, %if.then