[PATCH] D50841: [TableGen] TypeSetByHwMode::operator== optimization

Krzysztof Parzyszek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 16 07:47:24 PDT 2018


kparzysz added a comment.

A bit of a background for clarity: `<Something>ByHwMode` represents `<Something>` parameterized by hardware mode. It's a map that to each hw mode assigns the corresponding value of `<Something>`. If a value for mode `m` is missing from the map, the default is used (this is a form of compression).

`TypeSetByHwMode` are sets of `MVT`s corresponding to hw modes. They are used in definitions of `RegisterClass`es, so that a given class can have value types `i32` and `v2i16` in 32-bit mode, and `i64`, `v2i32`, and `v4i16` in 64-bit mode.

Here, the attempt here was to compare the two parameterized type sets taking into account that if the set for a particular mode is missing, the default will be assumed.  Specifically,

  default -> { i32 }

should compare identical to

  default -> { i32 }
  mode0 -> { i32 }

and similarly

  default -> { i32 }
  mode0 -> { i32 }

should compare identical to

  default -> { i32 }
  mode0 -> { i32 }
  mode1 -> { i32 }

On targets that don't use this feature, all `TypeSetByHwMode`s are in the form of a map with a single entry: `default -> { ... }`, which is what `isSimple` checks for.  The case where both parameterized sets are simple is the case for X86 and most other targets, so I agree that it should be made fast.  If any of them isn't simple, it means that we are dealing with parameterized sets and they should be handled more carefully.  The `return false` at line 208 in the original code was erroneous, since it did not perform the expanded checks in that specific case.


Repository:
  rL LLVM

https://reviews.llvm.org/D50841





More information about the llvm-commits mailing list