xref: /aosp_15_r20/external/llvm/test/Transforms/InstSimplify/shift-128-kb.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; NOTE: Assertions have been autogenerated by update_test_checks.py
2*9880d681SAndroid Build Coastguard Worker; RUN: opt -S -instsimplify < %s | FileCheck %s
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Workertarget datalayout = "E-m:e-i64:64-n32:64"
5*9880d681SAndroid Build Coastguard Workertarget triple = "powerpc64-unknown-linux-gnu"
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Workerdefine zeroext i1 @_Z10isNegativemj(i64 %Val, i32 zeroext %IntegerBitWidth) {
8*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @_Z10isNegativemj(
9*9880d681SAndroid Build Coastguard Worker; CHECK:         [[CONV:%.*]] = zext i32 %IntegerBitWidth to i64
10*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    [[SUB:%.*]] = sub i64 128, [[CONV]]
11*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    [[CONV1:%.*]] = trunc i64 [[SUB]] to i32
12*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    [[CONV2:%.*]] = zext i64 %Val to i128
13*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    [[SH_PROM:%.*]] = zext i32 [[CONV1]] to i128
14*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    [[SHL:%.*]] = shl i128 [[CONV2]], [[SH_PROM]]
15*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    [[SHR:%.*]] = ashr i128 [[SHL]], [[SH_PROM]]
16*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    [[CMP:%.*]] = icmp slt i128 [[SHR]], 0
17*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:    ret i1 [[CMP]]
18*9880d681SAndroid Build Coastguard Worker;
19*9880d681SAndroid Build Coastguard Workerentry:
20*9880d681SAndroid Build Coastguard Worker  %conv = zext i32 %IntegerBitWidth to i64
21*9880d681SAndroid Build Coastguard Worker  %sub = sub i64 128, %conv
22*9880d681SAndroid Build Coastguard Worker  %conv1 = trunc i64 %sub to i32
23*9880d681SAndroid Build Coastguard Worker  %conv2 = zext i64 %Val to i128
24*9880d681SAndroid Build Coastguard Worker  %sh_prom = zext i32 %conv1 to i128
25*9880d681SAndroid Build Coastguard Worker  %shl = shl i128 %conv2, %sh_prom
26*9880d681SAndroid Build Coastguard Worker  %shr = ashr i128 %shl, %sh_prom
27*9880d681SAndroid Build Coastguard Worker  %cmp = icmp slt i128 %shr, 0
28*9880d681SAndroid Build Coastguard Worker  ret i1 %cmp
29*9880d681SAndroid Build Coastguard Worker}
30*9880d681SAndroid Build Coastguard Worker
31