xref: /llvm-project/llvm/test/Transforms/InstCombine/neg-alloca.ll (revision 4ab40eca080965c65802710e39adbb78c4ce7bde)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=instcombine -S | FileCheck %s
3declare void @use(ptr)
4
5define void @foo(i64 %X) {
6; Currently we cannot handle expressions of the form Offset - X * Scale.
7; CHECK-LABEL: @foo(
8; CHECK-NEXT:    [[TMP1:%.*]] = shl i64 [[X:%.*]], 2
9; CHECK-NEXT:    [[TMP2:%.*]] = sub i64 24, [[TMP1]]
10; CHECK-NEXT:    [[TMP3:%.*]] = alloca i8, i64 [[TMP2]], align 4
11; CHECK-NEXT:    call void @use(ptr nonnull [[TMP3]])
12; CHECK-NEXT:    ret void
13;
14  %1 = mul nsw i64 %X, -4
15  %2 = add nsw i64 %1, 24
16  %3 = alloca i8, i64 %2, align 4
17  call void @use(ptr %3)
18  ret void
19}
20