llvmpipe: Optimize away min/max with equal operands.
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_arit.c b/src/gallium/drivers/llvmpipe/lp_bld_arit.c
index ba272df..db0db02 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_arit.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_arit.c
@@ -288,6 +288,14 @@
    }
    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 @@
    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 @@
    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;