snake5 icon

shader compiler IR dump - constant propagation 2

snake5 | PRO | 01/04/18 07:21:09 AM UTC | 0 ⭐ | 768 👁️ | Never ⏰ | []
LLVM |

1.87 KB

|

None

|

0 👍

/

0 👎

----- subtest:[unary operators] -----
function float4 main():POSITION // mangledName=main
{
  return cast[float4] binop(+) [float]
  {
    binop(+) [float]
    {
      binop(+) [float]
      {
        binop(+) [float]
        {
          cast[float] int32(0)
          unop(-) [float]
          {
            float32(0.1)
          }
        }
        cast[float] unop(~) [int]
        {
          unop(~) [int]
          {
            int32(0)
          }
        }
      }
      cast[float] unop(!) [bool]
      {
        cast[bool] int32(0)
      }
    }
    cast[float] unop(!) [bool]
    {
      unop(!) [bool]
      {
        bool(0)
      }
    }
  }
}
 
original IR:
module
{
  struct:00E6B088:main__ret{ [4 x f32] __RetVal:POSITION }
  function 'main'() -> struct:00E6B088:main__ret
  {
    block
    {
      00E63780 = cast f32 i32:0
      00E63B20 = neg(f32:0.1)
      00E79900 = add(00E63780,00E63B20)
      00E6B110 = bitwise-inv(i32:0)
      00E81A38 = bitwise-inv(00E6B110)
      00E81A98 = cast f32 00E81A38
      00E79CF0 = add(00E79900,00E81A98)
      00E81AF8 = cast i1 i32:0
      00E7A168 = logical-inv(00E81AF8)
      00E7A1C8 = cast f32 00E7A168
      00E79970 = add(00E79CF0,00E7A1C8)
      00E82B98 = logical-inv(i1:0)
      00E82EF8 = logical-inv(00E82B98)
      00E82FB8 = cast f32 00E82EF8
      00E79660 = add(00E79970,00E82FB8)
      00E82D18 = cast [4 x f32] 00E79660
      00E83018 = aggregate struct:00E6B088:main__ret (00E82D18)
      ret struct:00E6B088:main__ret 00E83018
    }
  }
}
optimized IR:
module
{
  struct:00E6B088:main__ret{ [4 x f32] __RetVal:POSITION }
  function 'main'() -> struct:00E6B088:main__ret
  {
    block
    {
      00E82D18 = cast [4 x f32] f32:0.9
      00E83018 = aggregate struct:00E6B088:main__ret (00E82D18)
      ret struct:00E6B088:main__ret 00E83018
    }
  }
}

Comments