[llvm] r245444 - [SPARC] Fix BooleanContents, so that select of a trunc doesn't
James Y Knight via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 19 07:47:05 PDT 2015
Author: jyknight
Date: Wed Aug 19 09:47:04 2015
New Revision: 245444
URL: http://llvm.org/viewvc/llvm-project?rev=245444&view=rev
Log:
[SPARC] Fix BooleanContents, so that select of a trunc doesn't
eliminate the trunc.
Differential Revision: http://reviews.llvm.org/D10442
Added:
llvm/trunk/test/CodeGen/SPARC/select-mask.ll
Modified:
llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp
Modified: llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp?rev=245444&r1=245443&r2=245444&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp Wed Aug 19 09:47:04 2015
@@ -1423,6 +1423,14 @@ SparcTargetLowering::SparcTargetLowering
: TargetLowering(TM), Subtarget(&STI) {
MVT PtrVT = MVT::getIntegerVT(8 * TM.getPointerSize());
+ // Instructions which use registers as conditionals examine all the
+ // bits (as does the pseudo SELECT_CC expansion). I don't think it
+ // matters much whether it's ZeroOrOneBooleanContent, or
+ // ZeroOrNegativeOneBooleanContent, so, arbitrarily choose the
+ // former.
+ setBooleanContents(ZeroOrOneBooleanContent);
+ setBooleanVectorContents(ZeroOrOneBooleanContent);
+
// Set up the register classes.
addRegisterClass(MVT::i32, &SP::IntRegsRegClass);
addRegisterClass(MVT::f32, &SP::FPRegsRegClass);
Added: llvm/trunk/test/CodeGen/SPARC/select-mask.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SPARC/select-mask.ll?rev=245444&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/SPARC/select-mask.ll (added)
+++ llvm/trunk/test/CodeGen/SPARC/select-mask.ll Wed Aug 19 09:47:04 2015
@@ -0,0 +1,17 @@
+; RUN: llc -march=sparc < %s
+
+;; getBooleanContents on Sparc used to claim that no bits mattered
+;; other than the first for SELECT. Thus, the 'trunc' got eliminated
+;; as redundant. But, cmp does NOT ignore the other bits!
+
+; CHECK-LABEL select_mask:
+; CHECK: ldub [%o0], [[R:%[goli][0-7]]]
+; CHECK: and [[R]], 1, [[V:%[goli][0-7]]]
+; CHECK: cmp [[V]], 0
+define i32 @select_mask(i8* %this) {
+entry:
+ %bf.load2 = load i8, i8* %this, align 4
+ %bf.cast5 = trunc i8 %bf.load2 to i1
+ %cond = select i1 %bf.cast5, i32 2, i32 0
+ ret i32 %cond
+}
More information about the llvm-commits
mailing list