1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=inline,instcombine %s | FileCheck %s --check-prefixes=CHECK,CHECK-INLINE
3 ; RUN: opt -S -passes=instcombine %s | FileCheck %s --check-prefixes=CHECK,CHECK-NOINLINE
5 define ptr @widen_align_from_allocalign_callsite() {
6 ; CHECK-LABEL: @widen_align_from_allocalign_callsite(
8 ; CHECK-NEXT: [[CALL:%.*]] = tail call align 64 ptr @my_aligned_alloc_2(i32 noundef 320, i32 allocalign noundef 64)
9 ; CHECK-NEXT: ret ptr [[CALL]]
13 %call = tail call align 16 ptr @my_aligned_alloc_2(i32 noundef 320, i32 allocalign noundef 64)
17 define ptr @widen_align_from_allocalign() {
18 ; CHECK-LABEL: @widen_align_from_allocalign(
20 ; CHECK-NEXT: [[CALL:%.*]] = tail call align 64 ptr @my_aligned_alloc(i32 noundef 320, i32 noundef 64)
21 ; CHECK-NEXT: ret ptr [[CALL]]
25 %call = tail call align 16 ptr @my_aligned_alloc(i32 noundef 320, i32 noundef 64)
29 define ptr @dont_narrow_align_from_allocalign() {
30 ; CHECK-LABEL: @dont_narrow_align_from_allocalign(
32 ; CHECK-NEXT: [[CALL:%.*]] = tail call align 16 ptr @my_aligned_alloc(i32 noundef 320, i32 noundef 8)
33 ; CHECK-NEXT: ret ptr [[CALL]]
36 %call = tail call align 16 ptr @my_aligned_alloc(i32 noundef 320, i32 noundef 8)
40 define ptr @my_aligned_alloc_3(i32 noundef %foo, i32 allocalign %alignment) {
41 ; CHECK-LABEL: @my_aligned_alloc_3(
42 ; CHECK-NEXT: [[CALL:%.*]] = tail call ptr @my_aligned_alloc_2(i32 noundef [[FOO:%.*]], i32 noundef [[ALIGNMENT:%.*]])
43 ; CHECK-NEXT: ret ptr [[CALL]]
45 %call = tail call ptr @my_aligned_alloc_2(i32 noundef %foo, i32 noundef %alignment)
49 ; -passes=inline is able to make my_aligned_alloc_3's arguments disappear and directly
50 ; call my_aligned_alloc_2, but the latter has no allocalign so the alignment just
51 ; disappears. This is conservatively correct but undesirable because we can't
52 ; figure out the `align 128` on the return value once the call is directly on
53 ; my_aligned_alloc_2. Note that this is a simplified version of what happens
54 ; with _mm_malloc which calls posix_memalign.
55 define ptr @allocalign_disappears() {
56 ; CHECK-INLINE-LABEL: @allocalign_disappears(
57 ; CHECK-INLINE-NEXT: [[CALL_I:%.*]] = tail call ptr @my_aligned_alloc_2(i32 noundef 42, i32 noundef 128)
58 ; CHECK-INLINE-NEXT: ret ptr [[CALL_I]]
60 ; CHECK-NOINLINE-LABEL: @allocalign_disappears(
61 ; CHECK-NOINLINE-NEXT: [[CALL:%.*]] = tail call align 128 ptr @my_aligned_alloc_3(i32 42, i32 128)
62 ; CHECK-NOINLINE-NEXT: ret ptr [[CALL]]
64 %call = tail call ptr @my_aligned_alloc_3(i32 42, i32 128)
68 declare ptr @my_aligned_alloc(i32 noundef, i32 allocalign noundef)
69 declare ptr @my_aligned_alloc_2(i32 noundef, i32 noundef)