]> granicus.if.org Git - llvm/commitdiff
[InstCombine] remove unnecessary vector select fold; NFCI
authorSanjay Patel <spatel@rotateright.com>
Wed, 30 Aug 2017 14:04:57 +0000 (14:04 +0000)
committerSanjay Patel <spatel@rotateright.com>
Wed, 30 Aug 2017 14:04:57 +0000 (14:04 +0000)
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

lib/Transforms/InstCombine/InstCombineSelect.cpp
test/Transforms/InstSimplify/compare.ll
test/Transforms/InstSimplify/select.ll

index c43dad53704954a64a3f74caf0e7035a5977f2aa..11602ab101e21b9e2c0114b5d951d8106c7879e2 100644 (file)
@@ -1566,10 +1566,6 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
         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
index 2fe0790191616ef3f918522c701f596e0e8c7ded..d84e4986dbb39fdbfe9daf876d12c2836bbe4eef 100644 (file)
@@ -790,24 +790,6 @@ define i1 @non_inbounds_gep_compare2(i64* %a) {
 ; 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
index 6044d689e2d2feef95acd7ad9303cecb49f1e4c9..7ede76d4dfa3c9785afdcaef51d50a91682ab011 100644 (file)
@@ -1,6 +1,22 @@
 ; 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