[llvm] 3ab1334 - [InstCombine] Add tests for mul of abs intrinsic (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 5 03:38:58 PDT 2020
Author: Nikita Popov
Date: 2020-09-05T12:36:27+02:00
New Revision: 3ab13348ba4c25f12254dd6c772f9fb1060b4425
URL: https://github.com/llvm/llvm-project/commit/3ab13348ba4c25f12254dd6c772f9fb1060b4425
DIFF: https://github.com/llvm/llvm-project/commit/3ab13348ba4c25f12254dd6c772f9fb1060b4425.diff
LOG: [InstCombine] Add tests for mul of abs intrinsic (NFC)
Added:
Modified:
llvm/test/Transforms/InstCombine/mul.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/mul.ll b/llvm/test/Transforms/InstCombine/mul.ll
index 2e9250fe94c4..8d00ad560f9c 100644
--- a/llvm/test/Transforms/InstCombine/mul.ll
+++ b/llvm/test/Transforms/InstCombine/mul.ll
@@ -1,6 +1,8 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
+declare i32 @llvm.abs.i32(i32, i1)
+
define i32 @pow2_multiplier(i32 %A) {
; CHECK-LABEL: @pow2_multiplier(
; CHECK-NEXT: [[B:%.*]] = shl i32 [[A:%.*]], 1
@@ -858,6 +860,29 @@ define <4 x i32> @combine_mul_nabs_v4i32(<4 x i32> %0) {
ret <4 x i32> %m
}
+define i32 @combine_mul_abs_intrin(i32 %x) {
+; CHECK-LABEL: @combine_mul_abs_intrin(
+; CHECK-NEXT: [[ABS:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 false)
+; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[ABS]], [[ABS]]
+; CHECK-NEXT: ret i32 [[MUL]]
+;
+ %abs = call i32 @llvm.abs.i32(i32 %x, i1 false)
+ %mul = mul i32 %abs, %abs
+ ret i32 %mul
+}
+
+define i32 @combine_mul_nabs_intrin(i32 %x) {
+; CHECK-LABEL: @combine_mul_nabs_intrin(
+; CHECK-NEXT: [[ABS:%.*]] = call i32 @llvm.abs.i32(i32 [[X:%.*]], i1 false)
+; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[ABS]], [[ABS]]
+; CHECK-NEXT: ret i32 [[MUL]]
+;
+ %abs = call i32 @llvm.abs.i32(i32 %x, i1 false)
+ %neg = sub i32 0, %abs
+ %mul = mul i32 %neg, %neg
+ ret i32 %mul
+}
+
; z * splat(0) = splat(0), even for scalable vectors
define <vscale x 2 x i64> @mul_scalable_splat_zero(<vscale x 2 x i64> %z) {
; CHECK-LABEL: @mul_scalable_splat_zero(
More information about the llvm-commits
mailing list