xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/neg-shl-add.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=x86-64 < %s | not grep negq
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; These sequences don't need neg instructions; they can be done with
4*9880d681SAndroid Build Coastguard Worker; a single shift and sub each.
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workerdefine i64 @foo(i64 %x, i64 %y, i64 %n) nounwind {
7*9880d681SAndroid Build Coastguard Worker  %a = sub i64 0, %y
8*9880d681SAndroid Build Coastguard Worker  %b = shl i64 %a, %n
9*9880d681SAndroid Build Coastguard Worker  %c = add i64 %b, %x
10*9880d681SAndroid Build Coastguard Worker  ret i64 %c
11*9880d681SAndroid Build Coastguard Worker}
12*9880d681SAndroid Build Coastguard Workerdefine i64 @boo(i64 %x, i64 %y, i64 %n) nounwind {
13*9880d681SAndroid Build Coastguard Worker  %a = sub i64 0, %y
14*9880d681SAndroid Build Coastguard Worker  %b = shl i64 %a, %n
15*9880d681SAndroid Build Coastguard Worker  %c = add i64 %x, %b
16*9880d681SAndroid Build Coastguard Worker  ret i64 %c
17*9880d681SAndroid Build Coastguard Worker}
18