mirror of
				https://github.com/encounter/dawn-cmake.git
				synced 2025-10-26 03:30:30 +00:00 
			
		
		
		
	Prevents UB for divide-by-zero and integer overflow when dividing Fixed: tint:1349 Change-Id: Ieef66d27d7aec3011628ced076b2bccc7770a8af Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/108925 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
		
			
				
	
	
		
			51 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| ; SPIR-V
 | |
| ; Version: 1.3
 | |
| ; Generator: Google Tint Compiler; 0
 | |
| ; Bound: 34
 | |
| ; Schema: 0
 | |
|                OpCapability Shader
 | |
|                OpMemoryModel Logical GLSL450
 | |
|                OpEntryPoint GLCompute %f "f"
 | |
|                OpExecutionMode %f LocalSize 1 1 1
 | |
|                OpName %tint_div "tint_div"
 | |
|                OpName %lhs "lhs"
 | |
|                OpName %rhs "rhs"
 | |
|                OpName %f "f"
 | |
|         %int = OpTypeInt 32 1
 | |
|       %v3int = OpTypeVector %int 3
 | |
|           %1 = OpTypeFunction %v3int %v3int %int
 | |
|          %10 = OpConstantNull %v3int
 | |
|        %bool = OpTypeBool
 | |
|      %v3bool = OpTypeVector %bool 3
 | |
| %int_n2147483648 = OpConstant %int -2147483648
 | |
|          %15 = OpConstantComposite %v3int %int_n2147483648 %int_n2147483648 %int_n2147483648
 | |
|      %int_n1 = OpConstant %int -1
 | |
|          %18 = OpConstantComposite %v3int %int_n1 %int_n1 %int_n1
 | |
|       %int_1 = OpConstant %int 1
 | |
|          %23 = OpConstantComposite %v3int %int_1 %int_1 %int_1
 | |
|        %void = OpTypeVoid
 | |
|          %25 = OpTypeFunction %void
 | |
|       %int_2 = OpConstant %int 2
 | |
|       %int_3 = OpConstant %int 3
 | |
|          %31 = OpConstantComposite %v3int %int_1 %int_2 %int_3
 | |
|       %int_4 = OpConstant %int 4
 | |
|    %tint_div = OpFunction %v3int None %1
 | |
|         %lhs = OpFunctionParameter %v3int
 | |
|         %rhs = OpFunctionParameter %int
 | |
|           %7 = OpLabel
 | |
|           %8 = OpCompositeConstruct %v3int %rhs %rhs %rhs
 | |
|          %11 = OpIEqual %v3bool %8 %10
 | |
|          %16 = OpIEqual %v3bool %lhs %15
 | |
|          %19 = OpIEqual %v3bool %8 %18
 | |
|          %20 = OpLogicalAnd %v3bool %16 %19
 | |
|          %21 = OpLogicalOr %v3bool %11 %20
 | |
|           %9 = OpSelect %v3int %21 %23 %8
 | |
|          %24 = OpSDiv %v3int %lhs %9
 | |
|                OpReturnValue %24
 | |
|                OpFunctionEnd
 | |
|           %f = OpFunction %void None %25
 | |
|          %28 = OpLabel
 | |
|          %33 = OpFunctionCall %v3int %tint_div %31 %int_4
 | |
|                OpReturn
 | |
|                OpFunctionEnd
 |