xref: /llvm-project/llvm/test/Transforms/CodeGenPrepare/AArch64/trunc-weird-user.ll (revision f1ec0d12bb0843f0deab83ef2b5cf1339cbc4f0b)
1; RUN: opt -S -passes='require<profile-summary>,function(codegenprepare)' -mtriple=arm64-apple-ios7.0 %s | FileCheck %s
2
3%foo = type { i8 }
4
5define %foo @test_merge(i32 %in) {
6; CHECK-LABEL: @test_merge
7
8  ; CodeGenPrepare was requesting the EVT for { i8 } to determine
9  ; whether the insertvalue user of the trunc was legal. This
10  ; asserted.
11
12; CHECK: insertvalue %foo undef, i8 %byte, 0
13  %lobit = lshr i32 %in, 31
14  %byte = trunc i32 %lobit to i8
15  %struct = insertvalue %foo undef, i8 %byte, 0
16  ret %"foo" %struct
17}
18
19define ptr @test_merge_PR21548(i32 %a, ptr %p1, ptr %p2, ptr %p3) {
20; CHECK-LABEL: @test_merge_PR21548
21  %as = lshr i32 %a, 3
22  %Tr = trunc i32 %as to i1
23  br i1 %Tr, label %BB2, label %BB3
24
25BB2:
26  ; Similarly to above:
27  ; CodeGenPrepare was requesting the EVT for ptr to determine
28  ; whether the select user of the trunc was legal. This asserted.
29
30; CHECK: select i1 {{%.*}}, ptr %p1, ptr %p2
31  %p = select i1 %Tr, ptr %p1, ptr %p2
32  ret ptr %p
33
34BB3:
35  ret ptr %p3
36}
37