1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -O3 -S < %s | FileCheck %s --check-prefixes=ANY,OLDPM 3; RUN: opt -passes='default<O3>' -S < %s | FileCheck %s --check-prefixes=ANY,NEWPM 4 5; This should become a single funnel shift through a combination 6; of aggressive-instcombine, simplifycfg, and instcombine. 7; https://bugs.llvm.org/show_bug.cgi?id=34924 8; These are equivalent, but the value name with the new-pm shows a bug - 9; this code should not have been converted to a speculative select with 10; an intermediate transform. 11 12define i32 @rotl(i32 %a, i32 %b) { 13; OLDPM-LABEL: @rotl( 14; OLDPM-NEXT: entry: 15; OLDPM-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.fshl.i32(i32 [[A:%.*]], i32 [[A]], i32 [[B:%.*]]) 16; OLDPM-NEXT: ret i32 [[TMP0]] 17; 18; NEWPM-LABEL: @rotl( 19; NEWPM-NEXT: entry: 20; NEWPM-NEXT: [[SPEC_SELECT:%.*]] = tail call i32 @llvm.fshl.i32(i32 [[A:%.*]], i32 [[A]], i32 [[B:%.*]]) 21; NEWPM-NEXT: ret i32 [[SPEC_SELECT]] 22; 23entry: 24 %cmp = icmp eq i32 %b, 0 25 br i1 %cmp, label %end, label %rotbb 26 27rotbb: 28 %sub = sub i32 32, %b 29 %shr = lshr i32 %a, %sub 30 %shl = shl i32 %a, %b 31 %or = or i32 %shr, %shl 32 br label %end 33 34end: 35 %cond = phi i32 [ %or, %rotbb ], [ %a, %entry ] 36 ret i32 %cond 37} 38 39