[llvm] 0cd0ae1 - [InstCombine] add tests to show missing one-use checks; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 3 08:54:24 PDT 2020
Author: Sanjay Patel
Date: 2020-07-03T11:54:09-04:00
New Revision: 0cd0ae1f29ddaeaed8a9ada513d98f352bc97b46
URL: https://github.com/llvm/llvm-project/commit/0cd0ae1f29ddaeaed8a9ada513d98f352bc97b46
DIFF: https://github.com/llvm/llvm-project/commit/0cd0ae1f29ddaeaed8a9ada513d98f352bc97b46.diff
LOG: [InstCombine] add tests to show missing one-use checks; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/select-bitext.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/select-bitext.ll b/llvm/test/Transforms/InstCombine/select-bitext.ll
index d44be2735735..d39dca940ea8 100644
--- a/llvm/test/Transforms/InstCombine/select-bitext.ll
+++ b/llvm/test/Transforms/InstCombine/select-bitext.ll
@@ -1,6 +1,8 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
+declare void @use32(i32)
+
; Widen a select of constants to eliminate an extend.
define i16 @sel_sext_constants(i1 %cmp) {
@@ -451,6 +453,38 @@ define i32 @test_bits_zext(i8 %a, i1 %cc) {
ret i32 %r
}
+define i32 @sel_sext_const_uses(i8 %a, i8 %x) {
+; CHECK-LABEL: @sel_sext_const_uses(
+; CHECK-NEXT: [[COND:%.*]] = icmp ugt i8 [[X:%.*]], 15
+; CHECK-NEXT: [[A_EXT:%.*]] = sext i8 [[A:%.*]] to i32
+; CHECK-NEXT: call void @use32(i32 [[A_EXT]])
+; CHECK-NEXT: [[NARROW:%.*]] = select i1 [[COND]], i8 [[A]], i8 127
+; CHECK-NEXT: [[R:%.*]] = sext i8 [[NARROW]] to i32
+; CHECK-NEXT: ret i32 [[R]]
+;
+ %cond = icmp ugt i8 %x, 15
+ %a.ext = sext i8 %a to i32
+ call void @use32(i32 %a.ext)
+ %r = select i1 %cond, i32 %a.ext, i32 127
+ ret i32 %r
+}
+
+define i32 @sel_zext_const_uses(i8 %a, i8 %x) {
+; CHECK-LABEL: @sel_zext_const_uses(
+; CHECK-NEXT: [[COND:%.*]] = icmp sgt i8 [[X:%.*]], 15
+; CHECK-NEXT: [[A_EXT:%.*]] = zext i8 [[A:%.*]] to i32
+; CHECK-NEXT: call void @use32(i32 [[A_EXT]])
+; CHECK-NEXT: [[NARROW:%.*]] = select i1 [[COND]], i8 -1, i8 [[A]]
+; CHECK-NEXT: [[R:%.*]] = zext i8 [[NARROW]] to i32
+; CHECK-NEXT: ret i32 [[R]]
+;
+ %cond = icmp sgt i8 %x, 15
+ %a.ext = zext i8 %a to i32
+ call void @use32(i32 %a.ext)
+ %r = select i1 %cond, i32 255, i32 %a.ext
+ ret i32 %r
+}
+
define i32 @test_op_op(i32 %a, i32 %b, i32 %c) {
; CHECK-LABEL: @test_op_op(
; CHECK-NEXT: [[CCA:%.*]] = icmp sgt i32 [[A:%.*]], 0
More information about the llvm-commits
mailing list