[tint] Simplify std::optional equality comparisons

Instead of checking for the presence of an optional and then comparing
its `value()` to another value, we can just directly compare the
optional itself to the value, which takes care of checking presence
automatically.

Change-Id: I1562962c9239a96baf11847944539646b335c12f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/196818
Commit-Queue: James Price <jrprice@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
diff --git a/src/tint/lang/core/ir/transform/zero_init_workgroup_memory.cc b/src/tint/lang/core/ir/transform/zero_init_workgroup_memory.cc
index 8969c9f..28511b9 100644
--- a/src/tint/lang/core/ir/transform/zero_init_workgroup_memory.cc
+++ b/src/tint/lang/core/ir/transform/zero_init_workgroup_memory.cc
@@ -217,8 +217,7 @@
             if (auto* str = param->Type()->As<type::Struct>()) {
                 // Check each member for the local invocation index builtin attribute.
                 for (auto* member : str->Members()) {
-                    if (member->Attributes().builtin && member->Attributes().builtin.value() ==
-                                                            BuiltinValue::kLocalInvocationIndex) {
+                    if (member->Attributes().builtin == BuiltinValue::kLocalInvocationIndex) {
                         auto* access = b.Access(ty.u32(), param, u32(member->Index()));
                         access->InsertBefore(func->Block()->Front());
                         return access->Result(0);
@@ -226,8 +225,7 @@
                 }
             } else {
                 // Check if the parameter is the local invocation index.
-                if (param->Builtin() &&
-                    param->Builtin().value() == BuiltinValue::kLocalInvocationIndex) {
+                if (param->Builtin() == BuiltinValue::kLocalInvocationIndex) {
                     return param;
                 }
             }
diff --git a/src/tint/lang/spirv/writer/raise/shader_io.cc b/src/tint/lang/spirv/writer/raise/shader_io.cc
index 359e7fe..d48e436 100644
--- a/src/tint/lang/spirv/writer/raise/shader_io.cc
+++ b/src/tint/lang/spirv/writer/raise/shader_io.cc
@@ -92,7 +92,7 @@
 
             if (io.attributes.builtin) {
                 // SampleMask must be an array for Vulkan.
-                if (io.attributes.builtin.value() == core::BuiltinValue::kSampleMask) {
+                if (io.attributes.builtin == core::BuiltinValue::kSampleMask) {
                     io.type = ty.array<u32, 1>();
                 }
                 name << "_" << io.attributes.builtin.value();
@@ -149,11 +149,10 @@
         // Load the input from the global variable declared earlier.
         auto* ptr = ty.ptr(core::AddressSpace::kIn, inputs[idx].type, core::Access::kRead);
         auto* from = input_vars[idx]->Result(0);
-        if (inputs[idx].attributes.builtin) {
-            if (inputs[idx].attributes.builtin.value() == core::BuiltinValue::kSampleMask) {
-                // SampleMask becomes an array for SPIR-V, so load from the first element.
-                from = builder.Access(ptr, input_vars[idx], 0_u)->Result(0);
-            }
+
+        // SampleMask becomes an array for SPIR-V, so load from the first element.
+        if (inputs[idx].attributes.builtin == core::BuiltinValue::kSampleMask) {
+            from = builder.Access(ptr, input_vars[idx], 0_u)->Result(0);
         }
 
         auto* value = builder.Load(from)->Result(0);
@@ -171,16 +170,15 @@
         // Store the output to the global variable declared earlier.
         auto* ptr = ty.ptr(core::AddressSpace::kOut, outputs[idx].type, core::Access::kWrite);
         auto* to = output_vars[idx]->Result(0);
-        if (outputs[idx].attributes.builtin) {
-            if (outputs[idx].attributes.builtin.value() == core::BuiltinValue::kSampleMask) {
-                // SampleMask becomes an array for SPIR-V, so store to the first element.
-                to = builder.Access(ptr, to, 0_u)->Result(0);
-            }
 
-            // Clamp frag_depth values if necessary.
-            if (outputs[idx].attributes.builtin.value() == core::BuiltinValue::kFragDepth) {
-                value = ClampFragDepth(builder, value);
-            }
+        // SampleMask becomes an array for SPIR-V, so store to the first element.
+        if (outputs[idx].attributes.builtin == core::BuiltinValue::kSampleMask) {
+            to = builder.Access(ptr, to, 0_u)->Result(0);
+        }
+
+        // Clamp frag_depth values if necessary.
+        if (outputs[idx].attributes.builtin == core::BuiltinValue::kFragDepth) {
+            value = ClampFragDepth(builder, value);
         }
 
         // Convert f16 values to f32 values if needed.