Skip to content

Conversation

@lanza
Copy link
Member

@lanza lanza commented Nov 22, 2025

Stack from ghstack (oldest at bottom):

This commit implements three previously missing operations for ExtVectorBoolType:

  1. Element assignment (v[i] = value): Converts the packed integer representation
    to a padded vector, performs the element insertion, and converts back to
    integer form while preserving padding bits.

  2. Vector comparisons (==, !=, etc.): Extracts actual elements from padded
    storage using shufflevector, performs element-wise comparison, then pads
    the result back to storage size with undef for padding bits.

  3. Logical NOT (!v): Implemented as element-wise comparison with zero vector,
    following the same extract-operate-pad pattern as other comparisons.

All operations follow the ExtVectorBoolType storage model where N bool elements
are stored in an integer padded to at least 8 bits (1 byte). The implementation:

  • Bitcasts the integer storage to

    vector (P = padded storage size)

  • Uses shufflevector to extract (actual elements)
  • Performs the operation on actual elements
  • Uses shufflevector to pad result back to

    (undef for padding)

  • Bitcasts back to integer storage

This approach ensures padding bits remain undefined/unchanged and mirrors how
LLVM CodeGen handles these operations.

Test Plan:

  • Added comprehensive tests for element assignment, comparisons, and logical NOT
  • Tests verify both CIR output and LLVM lowering
  • All existing CIR CodeGen tests pass (395 tests, 380 passed, 14 unsupported, 1 expected fail)
  • Specific vector tests pass: vector.cpp, vectype.cpp, vectype-issized.c, vectype-ext.cpp

The implementation closely follows CodeGen patterns in CGExprScalar.cpp and
CGExpr.cpp, maintaining consistency with the original implementation approach.

[ghstack-poisoned]
lanza added a commit that referenced this pull request Nov 22, 2025
…ns, and logical NOT

This commit implements three previously missing operations for ExtVectorBoolType:

1. Element assignment (v[i] = value): Converts the packed integer representation
   to a padded vector, performs the element insertion, and converts back to
   integer form while preserving padding bits.

2. Vector comparisons (==, !=, etc.): Extracts actual elements from padded
   storage using shufflevector, performs element-wise comparison, then pads
   the result back to storage size with undef for padding bits.

3. Logical NOT (!v): Implemented as element-wise comparison with zero vector,
   following the same extract-operate-pad pattern as other comparisons.

All operations follow the ExtVectorBoolType storage model where N bool elements
are stored in an integer padded to at least 8 bits (1 byte). The implementation:
- Bitcasts the integer storage to <P x i1> vector (P = padded storage size)
- Uses shufflevector to extract <N x i1> (actual elements)
- Performs the operation on actual elements
- Uses shufflevector to pad result back to <P x i1> (undef for padding)
- Bitcasts back to integer storage

This approach ensures padding bits remain undefined/unchanged and mirrors how
LLVM CodeGen handles these operations.

Test Plan:
- Added comprehensive tests for element assignment, comparisons, and logical NOT
- Tests verify both CIR output and LLVM lowering
- All existing CIR CodeGen tests pass (395 tests, 380 passed, 14 unsupported, 1 expected fail)
- Specific vector tests pass: vector.cpp, vectype.cpp, vectype-issized.c, vectype-ext.cpp

The implementation closely follows CodeGen patterns in CGExprScalar.cpp and
CGExpr.cpp, maintaining consistency with the original implementation approach.


ghstack-source-id: f80584c
Pull-Request: #2004
[ghstack-poisoned]
lanza added a commit that referenced this pull request Nov 22, 2025
…ns, and logical NOT

This commit implements three previously missing operations for ExtVectorBoolType:

1. Element assignment (v[i] = value): Converts the packed integer representation
   to a padded vector, performs the element insertion, and converts back to
   integer form while preserving padding bits.

2. Vector comparisons (==, !=, etc.): Extracts actual elements from padded
   storage using shufflevector, performs element-wise comparison, then pads
   the result back to storage size with undef for padding bits.

3. Logical NOT (!v): Implemented as element-wise comparison with zero vector,
   following the same extract-operate-pad pattern as other comparisons.

All operations follow the ExtVectorBoolType storage model where N bool elements
are stored in an integer padded to at least 8 bits (1 byte). The implementation:
- Bitcasts the integer storage to <P x i1> vector (P = padded storage size)
- Uses shufflevector to extract <N x i1> (actual elements)
- Performs the operation on actual elements
- Uses shufflevector to pad result back to <P x i1> (undef for padding)
- Bitcasts back to integer storage

This approach ensures padding bits remain undefined/unchanged and mirrors how
LLVM CodeGen handles these operations.

Test Plan:
- Added comprehensive tests for element assignment, comparisons, and logical NOT
- Tests verify both CIR output and LLVM lowering
- All existing CIR CodeGen tests pass (395 tests, 380 passed, 14 unsupported, 1 expected fail)
- Specific vector tests pass: vector.cpp, vectype.cpp, vectype-issized.c, vectype-ext.cpp

The implementation closely follows CodeGen patterns in CGExprScalar.cpp and
CGExpr.cpp, maintaining consistency with the original implementation approach.

ghstack-source-id: a9c5e91
Pull-Request: #2004
lanza added a commit that referenced this pull request Nov 22, 2025
…ns, and logical NOT

This commit implements three previously missing operations for ExtVectorBoolType:

1. Element assignment (v[i] = value): Converts the packed integer representation
   to a padded vector, performs the element insertion, and converts back to
   integer form while preserving padding bits.

2. Vector comparisons (==, !=, etc.): Extracts actual elements from padded
   storage using shufflevector, performs element-wise comparison, then pads
   the result back to storage size with undef for padding bits.

3. Logical NOT (!v): Implemented as element-wise comparison with zero vector,
   following the same extract-operate-pad pattern as other comparisons.

All operations follow the ExtVectorBoolType storage model where N bool elements
are stored in an integer padded to at least 8 bits (1 byte). The implementation:
- Bitcasts the integer storage to <P x i1> vector (P = padded storage size)
- Uses shufflevector to extract <N x i1> (actual elements)
- Performs the operation on actual elements
- Uses shufflevector to pad result back to <P x i1> (undef for padding)
- Bitcasts back to integer storage

This approach ensures padding bits remain undefined/unchanged and mirrors how
LLVM CodeGen handles these operations.

Test Plan:
- Added comprehensive tests for element assignment, comparisons, and logical NOT
- Tests verify both CIR output and LLVM lowering
- All existing CIR CodeGen tests pass (395 tests, 380 passed, 14 unsupported, 1 expected fail)
- Specific vector tests pass: vector.cpp, vectype.cpp, vectype-issized.c, vectype-ext.cpp

The implementation closely follows CodeGen patterns in CGExprScalar.cpp and
CGExpr.cpp, maintaining consistency with the original implementation approach.

ghstack-source-id: a9c5e91
Pull-Request: #2004
lanza added a commit that referenced this pull request Nov 24, 2025
…ns, and logical NOT

This commit implements three previously missing operations for ExtVectorBoolType:

1. Element assignment (v[i] = value): Converts the packed integer representation
   to a padded vector, performs the element insertion, and converts back to
   integer form while preserving padding bits.

2. Vector comparisons (==, !=, etc.): Extracts actual elements from padded
   storage using shufflevector, performs element-wise comparison, then pads
   the result back to storage size with undef for padding bits.

3. Logical NOT (!v): Implemented as element-wise comparison with zero vector,
   following the same extract-operate-pad pattern as other comparisons.

All operations follow the ExtVectorBoolType storage model where N bool elements
are stored in an integer padded to at least 8 bits (1 byte). The implementation:
- Bitcasts the integer storage to <P x i1> vector (P = padded storage size)
- Uses shufflevector to extract <N x i1> (actual elements)
- Performs the operation on actual elements
- Uses shufflevector to pad result back to <P x i1> (undef for padding)
- Bitcasts back to integer storage

This approach ensures padding bits remain undefined/unchanged and mirrors how
LLVM CodeGen handles these operations.

Test Plan:
- Added comprehensive tests for element assignment, comparisons, and logical NOT
- Tests verify both CIR output and LLVM lowering
- All existing CIR CodeGen tests pass (395 tests, 380 passed, 14 unsupported, 1 expected fail)
- Specific vector tests pass: vector.cpp, vectype.cpp, vectype-issized.c, vectype-ext.cpp

The implementation closely follows CodeGen patterns in CGExprScalar.cpp and
CGExpr.cpp, maintaining consistency with the original implementation approach.

ghstack-source-id: a9c5e91
Pull-Request: #2004
[ghstack-poisoned]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants