[llvm] r297304 - GlobalISel: correctly handle trivial fcmp predicates.
Tim Northover via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 8 10:49:55 PST 2017
Author: tnorthover
Date: Wed Mar 8 12:49:54 2017
New Revision: 297304
URL: http://llvm.org/viewvc/llvm-project?rev=297304&view=rev
Log:
GlobalISel: correctly handle trivial fcmp predicates.
It makes sense to only do them once in IRTranslator rather than making everyone
deal with them.
Modified:
llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
Modified: llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp?rev=297304&r1=297303&r2=297304&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp Wed Mar 8 12:49:54 2017
@@ -193,9 +193,12 @@ bool IRTranslator::translateCompare(cons
CmpInst::Predicate Pred =
CI ? CI->getPredicate() : static_cast<CmpInst::Predicate>(
cast<ConstantExpr>(U).getPredicate());
-
if (CmpInst::isIntPredicate(Pred))
MIRBuilder.buildICmp(Pred, Res, Op0, Op1);
+ else if (Pred == CmpInst::FCMP_FALSE)
+ MIRBuilder.buildConstant(Res, 0);
+ else if (Pred == CmpInst::FCMP_TRUE)
+ MIRBuilder.buildConstant(Res, 1);
else
MIRBuilder.buildFCmp(Pred, Res, Op0, Op1);
Modified: llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll?rev=297304&r1=297303&r2=297304&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll Wed Mar 8 12:49:54 2017
@@ -1056,6 +1056,17 @@ define void @float_comparison(float* %a.
ret void
}
+; CHECK-LABEL: name: trivial_float_comparison
+; CHECK: [[R1:%[0-9]+]](s1) = G_CONSTANT i1 false
+; CHECK: [[R2:%[0-9]+]](s1) = G_CONSTANT i1 true
+; CHECK: G_ADD [[R1]], [[R2]]
+define i1 @trivial_float_comparison(double %a, double %b) {
+ %r1 = fcmp false double %a, %b
+ %r2 = fcmp true double %a, %b
+ %sum = add i1 %r1, %r2
+ ret i1 %sum
+}
+
@var = global i32 0
define i32* @test_global() {
More information about the llvm-commits
mailing list