From 17f4bfb8d089e182b629eb26e51e6122270546b4 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Wed, 30 Aug 2017 14:04:57 +0000 Subject: [PATCH] [InstCombine] remove unnecessary vector select fold; NFCI 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 --- .../InstCombine/InstCombineSelect.cpp | 4 ---- test/Transforms/InstSimplify/compare.ll | 18 ------------------ test/Transforms/InstSimplify/select.ll | 16 ++++++++++++++++ 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/lib/Transforms/InstCombine/InstCombineSelect.cpp b/lib/Transforms/InstCombine/InstCombineSelect.cpp index c43dad53704..11602ab101e 100644 --- a/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -1566,10 +1566,6 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { return replaceInstUsesWith(SI, V); return &SI; } - - if (isa(CondVal)) { - return replaceInstUsesWith(SI, FalseVal); - } } // See if we can determine the result of this select based on a dominating diff --git a/test/Transforms/InstSimplify/compare.ll b/test/Transforms/InstSimplify/compare.ll index 2fe07901916..d84e4986dbb 100644 --- a/test/Transforms/InstSimplify/compare.ll +++ b/test/Transforms/InstSimplify/compare.ll @@ -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 diff --git a/test/Transforms/InstSimplify/select.ll b/test/Transforms/InstSimplify/select.ll index 6044d689e2d..7ede76d4dfa 100644 --- a/test/Transforms/InstSimplify/select.ll +++ b/test/Transforms/InstSimplify/select.ll @@ -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>, <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>, <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 -- 2.50.1