i965: Allow immediates to be folded into logical and shift instructions.
authorMatt Turner <mattst88@gmail.com>
Mon, 5 Aug 2013 22:17:04 +0000 (15:17 -0700)
committerMatt Turner <mattst88@gmail.com>
Mon, 9 Sep 2013 22:01:08 +0000 (15:01 -0700)
These instructions will be used with immediate arguments in the upcoming
ldexp lowering pass and frexp implementation.

v2: Add vec4 support as well.
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp

index 2780ab6fd6d6663f0770a338a725377edd683ab0..034ebef9917e9c4f5a8ed0e5f1cb45a9f9551f7d 100644 (file)
@@ -341,9 +341,20 @@ fs_visitor::try_constant_propagate(fs_inst *inst, acp_entry *entry)
          progress = true;
          break;
 
+      case BRW_OPCODE_SHL:
+      case BRW_OPCODE_SHR:
+         if (i == 1) {
+            inst->src[i] = entry->src;
+            progress = true;
+         }
+         break;
+
       case BRW_OPCODE_MACH:
       case BRW_OPCODE_MUL:
       case BRW_OPCODE_ADD:
+      case BRW_OPCODE_OR:
+      case BRW_OPCODE_AND:
+      case BRW_OPCODE_XOR:
          if (i == 1) {
             inst->src[i] = entry->src;
             progress = true;
index fdbe96c2e01d36f84a8e627543a1dda3d46d69f0..cd2b11831aea0b1d14c71b853fc07048b69abdef 100644 (file)
@@ -95,9 +95,20 @@ try_constant_propagation(vec4_instruction *inst, int arg, src_reg *values[4])
       inst->src[arg] = value;
       return true;
 
+   case BRW_OPCODE_SHL:
+   case BRW_OPCODE_SHR:
+      if (arg == 1) {
+         inst->src[arg] = value;
+         return true;
+      }
+      break;
+
    case BRW_OPCODE_MACH:
    case BRW_OPCODE_MUL:
    case BRW_OPCODE_ADD:
+   case BRW_OPCODE_OR:
+   case BRW_OPCODE_AND:
+   case BRW_OPCODE_XOR:
       if (arg == 1) {
         inst->src[arg] = value;
         return true;