summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-08-03 19:31:56 +0100
committerJosé Fonseca <jfonseca@vmware.com>2009-08-29 09:21:22 +0100
commit02eaa32d83637d6f60685afe5d29aeb06345e60e (patch)
tree2666ec07477290a7ed5c5933708421ca4a8576a0
parent9e922444403d704f9ed0cf50e510fba53c736b57 (diff)
llvmpipe: Optimize away min/max with equal operands.
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_arit.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_arit.c b/src/gallium/drivers/llvmpipe/lp_bld_arit.c
index ba272df296..db0db02c15 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_arit.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_arit.c
@@ -288,6 +288,14 @@ lp_build_intrinsic_binary(LLVMBuilderRef builder,
}
assert(LLVMIsDeclaration(function));
+#ifdef DEBUG
+ /* We shouldn't use only constants with intrinsics, as they won't be
+ * propagated by LLVM optimization passes.
+ */
+ if(LLVMIsConstant(a) && LLVMIsConstant(b))
+ debug_printf("warning: invoking intrinsic \"%s\" with constants\n");
+#endif
+
args[0] = a;
args[1] = b;
@@ -678,6 +686,9 @@ lp_build_min(struct lp_build_context *bld,
if(a == bld->undef || b == bld->undef)
return bld->undef;
+ if(a == b)
+ return a;
+
if(bld->type.norm) {
if(a == bld->zero || b == bld->zero)
return bld->zero;
@@ -699,6 +710,9 @@ lp_build_max(struct lp_build_context *bld,
if(a == bld->undef || b == bld->undef)
return bld->undef;
+ if(a == b)
+ return a;
+
if(bld->type.norm) {
if(a == bld->one || b == bld->one)
return bld->one;