This code is double-dead:
1. We simplify all selects with constant true/false condition in InstSimplify.
I've minimized/moved the tests to show that works as expected.
2. All remaining vector selects with a constant condition are canonicalized to
shufflevector, so we really can't see this pattern.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312123
91177308-0d34-0410-b5e6-
96231b3b80d8
return replaceInstUsesWith(SI, V);
return &SI;
}
-
- if (isa<ConstantAggregateZero>(CondVal)) {
- return replaceInstUsesWith(SI, FalseVal);
- }
}
// See if we can determine the result of this select based on a dominating
; CHECK-NEXT: ret i1 true
}
-define <4 x i8> @vectorselectfold(<4 x i8> %a, <4 x i8> %b) {
- %false = icmp ne <4 x i8> zeroinitializer, zeroinitializer
- %sel = select <4 x i1> %false, <4 x i8> %a, <4 x i8> %b
- ret <4 x i8> %sel
-
-; CHECK-LABEL: @vectorselectfold
-; CHECK-NEXT: ret <4 x i8> %b
-}
-
-define <4 x i8> @vectorselectfold2(<4 x i8> %a, <4 x i8> %b) {
- %true = icmp eq <4 x i8> zeroinitializer, zeroinitializer
- %sel = select <4 x i1> %true, <4 x i8> %a, <4 x i8> %b
- ret <4 x i8> %sel
-
-; CHECK-LABEL: @vectorselectfold
-; CHECK-NEXT: ret <4 x i8> %a
-}
-
define i1 @compare_always_true_slt(i16 %a) {
%1 = zext i16 %a to i32
%2 = sub nsw i32 0, %1
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instsimplify -S | FileCheck %s
+define <2 x i8> @vsel_tvec(<2 x i8> %x, <2 x i8> %y) {
+; CHECK-LABEL: @vsel_tvec(
+; CHECK-NEXT: ret <2 x i8> %x
+;
+ %s = select <2 x i1><i1 true, i1 true>, <2 x i8> %x, <2 x i8> %y
+ ret <2 x i8> %s
+}
+
+define <2 x i8> @vsel_fvec(<2 x i8> %x, <2 x i8> %y) {
+; CHECK-LABEL: @vsel_fvec(
+; CHECK-NEXT: ret <2 x i8> %y
+;
+ %s = select <2 x i1><i1 false, i1 false>, <2 x i8> %x, <2 x i8> %y
+ ret <2 x i8> %s
+}
+
define i32 @test1(i32 %x) {
; CHECK-LABEL: @test1(
; CHECK-NEXT: ret i32 %x