llvm.org GIT mirror llvm / d4415e8
[PhaseOrdering] add test for funnel shift (rotate); NFC As mentioned in D55604, there are 2 bugs here: 1. The new pass manager is speculating wildly by default. 2. The old pass manager is not converting this to funnel shift. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@348980 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 9 months ago
1 changed file(s) with 49 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt -O3 -S < %s | FileCheck %s --check-prefixes=ANY,OLDPM
2 ; RUN: opt -passes='default' -S < %s | FileCheck %s --check-prefixes=ANY,NEWPM
3
4 ; This should become a single funnel shift through a combination
5 ; of aggressive-instcombine, simplifycfg, and instcombine.
6 ; https://bugs.llvm.org/show_bug.cgi?id=34924
7
8 define i32 @rotl(i32 %a, i32 %b) {
9 ; OLDPM-LABEL: @rotl(
10 ; OLDPM-NEXT: entry:
11 ; OLDPM-NEXT: [[CMP:%.*]] = icmp eq i32 [[B:%.*]], 0
12 ; OLDPM-NEXT: br i1 [[CMP]], label [[END:%.*]], label [[ROTBB:%.*]]
13 ; OLDPM: rotbb:
14 ; OLDPM-NEXT: [[SUB:%.*]] = sub i32 32, [[B]]
15 ; OLDPM-NEXT: [[SHR:%.*]] = lshr i32 [[A:%.*]], [[SUB]]
16 ; OLDPM-NEXT: [[SHL:%.*]] = shl i32 [[A]], [[B]]
17 ; OLDPM-NEXT: [[OR:%.*]] = or i32 [[SHR]], [[SHL]]
18 ; OLDPM-NEXT: br label [[END]]
19 ; OLDPM: end:
20 ; OLDPM-NEXT: [[COND:%.*]] = phi i32 [ [[OR]], [[ROTBB]] ], [ [[A]], [[ENTRY:%.*]] ]
21 ; OLDPM-NEXT: ret i32 [[COND]]
22 ;
23 ; NEWPM-LABEL: @rotl(
24 ; NEWPM-NEXT: entry:
25 ; NEWPM-NEXT: [[TMP0:%.*]] = sub i32 0, [[B:%.*]]
26 ; NEWPM-NEXT: [[TMP1:%.*]] = and i32 [[B]], 31
27 ; NEWPM-NEXT: [[TMP2:%.*]] = and i32 [[TMP0]], 31
28 ; NEWPM-NEXT: [[TMP3:%.*]] = lshr i32 [[A:%.*]], [[TMP2]]
29 ; NEWPM-NEXT: [[TMP4:%.*]] = shl i32 [[A]], [[TMP1]]
30 ; NEWPM-NEXT: [[SPEC_SELECT:%.*]] = or i32 [[TMP3]], [[TMP4]]
31 ; NEWPM-NEXT: ret i32 [[SPEC_SELECT]]
32 ;
33 entry:
34 %cmp = icmp eq i32 %b, 0
35 br i1 %cmp, label %end, label %rotbb
36
37 rotbb:
38 %sub = sub i32 32, %b
39 %shr = lshr i32 %a, %sub
40 %shl = shl i32 %a, %b
41 %or = or i32 %shr, %shl
42 br label %end
43
44 end:
45 %cond = phi i32 [ %or, %rotbb ], [ %a, %entry ]
46 ret i32 %cond
47 }
48