[PATCH] D14877: Fix ICE on lowering of constexpr vector splats

George Burgess IV via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 20 11:04:33 PST 2015


george.burgess.iv created this revision.
george.burgess.iv added a reviewer: rsmith.
george.burgess.iv added a subscriber: cfe-commits.

When evaluating constexpr vector splats, we weren't doing appropriate type conversions on the literal we were splatting, causing assertion failures in cases like:

```
void foo(vector float FloatInput, vector short ShortInput) {
  (void)(FloatInput == (vector float)0); // OK
  (void)(ShortInput == (vector short)0); // OK

  constexpr vector float Floats = (vector float)0;
  (void)(FloatInput == Floats); // ICE -- fcmp between [4 x i32] and [4 x f32]

  constexpr vector short Shorts = (vector short)0;
  (void)(ShortInput == Shorts); // ICE -- fcmp between vec of i16 and vec of i32
}
```

(The same issue applied for cases like `(vector short)0`; it would be lowered as a vector of `i32`.)

This patch fixes these in ExprConstant rather than CodeGen, because it allows us to more sanely model overflow/complain to the user/... in the evaluator. 

This patch also contains a few generic code cleanliness changes. I'm happy to drop any/all of them if we decide they're not helpful. :)

http://reviews.llvm.org/D14877

Files:
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGExprConstant.cpp
  test/CodeGenCXX/builtins-systemz-zvector.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14877.40798.patch
Type: text/x-patch
Size: 6619 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151120/55a32c5f/attachment-0001.bin>


More information about the cfe-commits mailing list