Fixes https://bugs.llvm.org/show_bug.cgi?id=40172. See
test/CodeGen/WebAssembly/bug-40172.ll for an explanation. The changes
to X86 codegen are unfortunate if they are unnecessary, and I'd be
happy to accept feedback on how to make this fix less disruptive.
Details
Diff Detail
- Repository
- rL LLVM
- Build Status
Buildable 26480 Build 26479: arc lint + arc unit
Event Timeline
Is the zext/cmp optimization in WebAssemblyFastISel::zeroExtendToI32 really valid? Do other targets do that? If that had instead emitted an And with i1 like X86 does. The any_extend wouldn't have been an issue.
The FastISel optimization is correct as long as the CmpInst is also lowered by FastISel. I will have to think more about whether that is a valid assumption. But that FastISel logic does not actually affect the bug in question. See the continued discussion on the bug itself.
One question I have about this is whether BooleanContents should apply to *all* i1 values, which is what this patch assumes, or whether it should only apply to certain i1 values that are logically Boolean because they are the result of a setcc or similar. If BooleanContents should only apply to some i1s, this fix is overly conservative.