diff --git a/lib/Transforms/Vectorize/VectorCombine.cpp b/lib/Transforms/Vectorize/VectorCombine.cpp index 7faba73abf0..03fdda09358 100644 --- a/lib/Transforms/Vectorize/VectorCombine.cpp +++ b/lib/Transforms/Vectorize/VectorCombine.cpp @@ -670,6 +670,10 @@ bool VectorCombine::run() { if (DisableVectorCombine) return false; + // Don't attempt vectorization if the target does not support vectors. + if (!TTI.getNumberOfRegisters(TTI.getRegisterClassForType(/*Vector*/ true))) + return false; + bool MadeChange = false; for (BasicBlock &BB : F) { // Ignore unreachable basic blocks. diff --git a/test/Transforms/VectorCombine/X86/no-sse.ll b/test/Transforms/VectorCombine/X86/no-sse.ll index ccf0e0d29df..bd1806b0f1f 100644 --- a/test/Transforms/VectorCombine/X86/no-sse.ll +++ b/test/Transforms/VectorCombine/X86/no-sse.ll @@ -1,9 +1,12 @@ -; RUN: opt < %s -vector-combine -S -mtriple=x86_64-- -mattr=-sse | FileCheck %s --check-prefixes=CHECK +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -vector-combine -S -mtriple=x86_64-- -mattr=-sse | FileCheck %s + +; Don't spend time on vector transforms if the target does not support vectors. define <4 x float> @bitcast_shuf_same_size(<4 x i32> %v) { ; CHECK-LABEL: @bitcast_shuf_same_size( -; CHECK-NEXT: [[TMP1:%.*]] = bitcast <4 x i32> [[V:%.*]] to <4 x float> -; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> undef, <4 x i32> +; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[V:%.*]], <4 x i32> undef, <4 x i32> +; CHECK-NEXT: [[R:%.*]] = bitcast <4 x i32> [[SHUF]] to <4 x float> ; CHECK-NEXT: ret <4 x float> [[R]] ; %shuf = shufflevector <4 x i32> %v, <4 x i32> undef, <4 x i32>