[llvm] r335506 - [InstCombine] add tests for add-of-sext-bool; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 25 10:52:10 PDT 2018
Author: spatel
Date: Mon Jun 25 10:52:10 2018
New Revision: 335506
URL: http://llvm.org/viewvc/llvm-project?rev=335506&view=rev
Log:
[InstCombine] add tests for add-of-sext-bool; NFC
We canonicalize to select with a zext-add and either zext-sub or sext-sub,
so this shows a pattern that's not conforming to the general trend.
Modified:
llvm/trunk/test/Transforms/InstCombine/add.ll
Modified: llvm/trunk/test/Transforms/InstCombine/add.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/add.ll?rev=335506&r1=335505&r2=335506&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/add.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/add.ll Mon Jun 25 10:52:10 2018
@@ -23,6 +23,28 @@ define <2 x i32> @select_0_or_1_from_boo
ret <2 x i32> %add
}
+define i32 @select_C_minus_1_or_C_from_bool(i1 %x) {
+; CHECK-LABEL: @select_C_minus_1_or_C_from_bool(
+; CHECK-NEXT: [[EXT:%.*]] = sext i1 [[X:%.*]] to i32
+; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[EXT]], 42
+; CHECK-NEXT: ret i32 [[ADD]]
+;
+ %ext = sext i1 %x to i32
+ %add = add i32 %ext, 42
+ ret i32 %add
+}
+
+define <2 x i32> @select_C_minus_1_or_C_from_bool_vec(<2 x i1> %x) {
+; CHECK-LABEL: @select_C_minus_1_or_C_from_bool_vec(
+; CHECK-NEXT: [[EXT:%.*]] = sext <2 x i1> [[X:%.*]] to <2 x i32>
+; CHECK-NEXT: [[ADD:%.*]] = add nsw <2 x i32> [[EXT]], <i32 42, i32 43>
+; CHECK-NEXT: ret <2 x i32> [[ADD]]
+;
+ %ext = sext <2 x i1> %x to <2 x i32>
+ %add = add <2 x i32> %ext, <i32 42, i32 43>
+ ret <2 x i32> %add
+}
+
; This is an 'andn' of the low bit.
define i32 @flip_and_mask(i32 %x) {
More information about the llvm-commits
mailing list